我们可以单独使用Selenium网格在多台机器上并行运行测试用例吗?
现在我正在使用testNg来并行运行,但是我认为不使用TestNg就有可能实现并行执行。
这是现在的代码
public class TestingGrid {
WebDriver driver;
String baseURL,hubUrl;
@BeforeClass
@Parameters({ "browser" })
public void setUp(String browser) throws Exception {
baseURL = "http://demo.guru99.com/test/guru99home/";
InetAddress ipAddr = InetAddress.getLocalHost();
hubUrl = "http://"+ipAddr.getHostAddress()+":4444/wd/hub";
DesiredCapabilities capability = DesiredCapabilities.chrome();
capability.setBrowserName(browser);
driver = new RemoteWebDriver(new URL(hubUrl), capability);
}
@AfterTest
public void afterTest() {
driver.quit();
}
@Test
public void sampleTest() {
driver.get(baseURL);
String textByXpath = driver.findElement(By.xpath("/html/body/div[2]/section/div[1]/div/div/div/div[1]/div/div/div/div/div[1]/div/div/h2/font")).getText();
System.out.println("text for xpath:"+textByXpath);
}}