0
我正在探索在多個瀏覽器上執行測試的硒網格。我已經在線教程配置了集線器和節點。我創建了一個測試腳本。在多個瀏覽器上使用硒網格和testNG運行測試
下面是測試腳本的代碼:
public class SeleniumGridTest {
WebDriver driver;
String baseUrl, nodeUrl;
static FirefoxProfile myprofile;
@BeforeTest
public void beforeTest() throws MalformedURLException {
ProfilesIni profile = new ProfilesIni();
myprofile = profile.getProfile("SeleniumAuto");
nodeUrl = "http://10.233.18.60:5566/wd/hub";
DesiredCapabilities capability = DesiredCapabilities.firefox();
capability.setBrowserName("firefox");
capability.setCapability(FirefoxDriver.PROFILE, myprofile);
driver = new RemoteWebDriver(new URL(nodeUrl), capability);
}
@Test
public void google() {
driver.get("http://www.google.co.in");
System.out.println(driver.getCurrentUrl());
}
@Test
public void newtours() {
driver.get("http://newtours.demoaut.com");
System.out.println(driver.getCurrentUrl());
}
@AfterTest
public void afterTest() {
driver.quit();
}
}
我的目標是運行在多個瀏覽器 我已經加入想要的功能,像Firefox這樣的測試,
1)should I add desired capabilities for other browsers in the
@BeforeTest annotation? for eg capability.setBrowserName("chrome");
2)is that enough to run on multiple browsers.
3)If I have to run a suite of tests, where should I add the selenium grid configuration
details in all the tests or is it possible in testNG xml?
4)what is the best practice used in real time?
任何幫助讚賞