In addition, if running multiple parallel tests is required, maven surefire plugin with version equal or higher than 2.22.0 should be added to the plugins section:
Add plugin listener to your test class and extend the test class from CbTestNg
@Listeners(io.cloudbeat.testng.Plugin.class)
public class SeleniumTest extends CbTestNg {
}
Working with Selenium
When using Selenium it might be beneficiary to be able to take browser screenshots in case of failures.
Providing WebDriver instance
import io.cloudbeat.testng.CbTestNg;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
public class SeleniumTest extends CbTestNg {
@BeforeClass
public static void setUp() {
DesiredCapabilities capabilities = ... // User capabilities
// For default web browser initialization based on CloudBeat capabilities
setupWebDriver();
// For default web browser initialization based on user capabilities and CloudBeat capabilities
initWebDriver(capabilities);
// For default mobile driver initialization based on CloudBeat capabilities
setupMobDriver();
// For default web browser initialization based on user capabilities and CloudBeat capabilities
initMobDriver(capabilities);
//Or just setup your own driver
WebDriver driver = ... // Your driver initialization
setupDriver(driver); // Set up driver
this.driver; // Created driver
}
}
Custom steps
In order for CloudBeat to produce nicer repots, startStep and endStep methods can be used to designate test actions
import org.testng.annotations.Test;
public class SeleniumTest extends CbTestNg {
@Test
public void Test1() {
startStep("Step");
startStep("Inner step");
endStep("Inner step");
endStep("Step");
}
}