Test Driver for Browser Only Application
seetest.io cloud also provides browser only instances for testing.
Since browsers are less resource-intensive, it is fine to develop test suites with a view to run individual test methods in parallel.
In such scenarios language concept such as Java's ThreadLocal is a good choice which ensures returned drivers are per thread. Even if testA and testB are executed in parallel they will use a webdriver per thread thus avoiding conflicts.
public class WebTestExample {
...
private ThreadLocal<WebDriver> webDriver = new ThreadLocal<WebDriver>();
protected void createWebDriver() {
// Launch and set for the current thread.
webDriver.set(new RemoteWebDriver(new URL("https://cloud.seetest.io:443/wd/hub"), capabilities));
}
@Test
public void testA() {
// Get the driver for current thread.
WebDriver driver = createWebDriver().get();
....
}
@Test
public void testA() {
// Get the driver for current thread
WebDriver driver = createWebDriver().get();
....
}
}