我使用testNg +硒网格作为我的测试会话,我对整个东西感到非常满意 关键是测试的数量正在增长,现在他们至少需要3个hrs被执行(+ -100测试在TH浏览器) 我打算有+ -150测试,所以,你可以想象,我必须找到一个解决方案,并行启动他们 我试着玩这个,但没有现在运气好,我现在看到的是两个浏览器启动,但只有一个经过测试。另一个只是等待:-) 测试的结构如下,基本上是1测试= 1类。我在每次测试之前/之后都有@BeforeClass(启动驱动程序)和@AfterClass(停止驱动程序)testNG和硒在并行测试环境
testNG.xml - >我将parallel =更改为类,方法,测试但没有运气。数值!
<test name="Smoke Test in IE - IE REMOTE" preserve-order="true">
<parameter name="browser" value="IE" ></parameter>
<classes>
<class name="com.TestThis.Script1" />
<class name="com.TestThis.Script2" />
</classes>
</test>
TEST类如下所示 公共类SCRIPT1延伸SelTestCase {
try {
GlobalHelp.LogIn("usr","pwd");
customVerification.verifyTrue("Verify main page loaded(check download zone is visible!!)", ObjectHelp.isElementVisible(ObjectsPaths.Main_DownloadZone,120000)==true);
customVerification.SoftVerifyEquals("Verify main page is displayed " , driver.getTitle(), "Application Stuff");
} catch (Exception e) {
Reporter.log("from exception" + e.toString());
customVerification.verificationErrors.append(e);
}
}
}
与模块之前&后看起来像这样 公共类SelTestCase {
@BeforeSuite
@Parameters("appURL")
public void setEnv(
@Optional(ObjectsPaths.MAIN_URL) String appURL) {
this.appURL = appURL;
}
@BeforeClass
@Parameters({ "browser", "HUBip" })
public void launchBrowser(@Optional("IE") String browser, @Optional("localhost") String HUBip) throws MalformedURLException {
String brw=browser;
String ip=HUBip;
try {
if (sBrw.equalsIgnoreCase("Chrome")) {
URL url = new URL("http","localhost",4444, "/wd/hub");
DesiredCapabilities caps=DesiredCapabilities.chrome();
driver = new ScreenShotRemoteWebDriver(url, caps);
} else if (sBrw.equalsIgnoreCase("FF")) {
URL url = new URL("http", "localhost",4444, "/wd/hub")
DesiredCapabilities caps=DesiredCapabilities.firefox();
} else {
URL url = new URL("http", "localhost",4444, "/wd/hub");
DesiredCapabilities caps=DesiredCapabilities.internetExplorer();
driver = new ScreenShotRemoteWebDriver(url, caps);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
};
}
try {
Reporter.log("Test started at: " + ObjectHelp.getDate() + "<p>");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
driver.manage().timeouts().implicitlyWait(ObjectHelp.PAGE_LOAD_TIMEOUT, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(ObjectHelp.PAGE_LOAD_TIMEOUT,TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.navigate().to("http://www.google.com");
}
//TBD
@AfterClass
public void closeBrowser() throws Exception {
//driver.close();
QuitDriver();
}
你的问题是什么? – Shamik
问题是如何让它们并行运行! – user1944151
你的测试班如何获得驱动程序?看到我无法理解你的代码。但让我们清楚你是否想要并行运行测试(在相同或不同的浏览器中)它们应该得到不同的驱动程序。您的BeforeClass应该创建单独的驱动程序并传递到测试类。然后只有你可以达到你想要的。你在做那个吗? – Shamik