In the last post we discussed how selenium grid works and how to configure selenium grid in greater detail. In this post we will move further and try to run multiple tests in parallel in different environments like
Different Operating systems
Different browsers
Distributed architecture
The distributed architecture we will work will look something like this
Parallel execution
Parallel execution of test can be achieved using testing framework TestNG
In TestNG there is an option called Parallel which you can see from here
Here is the complete video of the above discussion
Here is the complete code from the above video
Parallel Execution Test Code
public class ParallelTest {
// RemotewebDriver instance
public static RemoteWebDriver driver;
@BeforeTest
@Parameters({ "platform", "browserName", "remoteurl" })
public void beforeTest(String platform, String browserName, String remoteurl)
throws MalformedURLException {
DesiredCapabilities cap = null;
if (browserName.equals("firefox")) {
cap = new DesiredCapabilities().firefox();
cap.setBrowserName("firefox");
} else if (browserName.equals("chrome")) {
cap = new DesiredCapabilities().chrome();
cap.setBrowserName("chrome");
}
cap.setPlatform(Platform.WIN8_1);
driver = new RemoteWebDriver(new URL(remoteurl), cap);
driver.navigate().to("http://www.google.com");
}
@Test
public void GoogleSearch() throws InterruptedException {
driver.findElementByName("q").sendKeys("execute automation");
driver.findElementByName("btnG").click();
Thread.sleep(3000);
}
@Test
public void ClickExecuteAutomation() {
driver.findElementByPartialLinkText("Execute Automation").click();
}
}
Thanks for reading the post and watching the video !!!
Please leave your comments and let me know if there is anything I should update in this post.
Thanks,
Karthik KK