我正在尝试在网格中运行selenium测试用例。我的集线器连接到2个selenium节点。虽然我试图在4个测试用例中运行selenium网格,但有时2个测试用例在2个节点上运行..其余测试用例我得到驱动程序初始化错误问题...
示例TestNG XML
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="ProductionSanity" parallel="tests" verbose="1">
<test name="aa1" >
<parameter name="customer" value="aa1" />
<classes>
<class name="com.test.ProdsanitySearch1" />
<class name="com.test.ProdsanitySearch11" />
</classes>
</test>
<test name="Gemes" >
<parameter name="customer" value="aa2" />
<classes>
class name="com.test.ProdsanitySearch2" />
<class name="com.test.ProdsanitySearch22" />
</classes>
</test>
</suite>
请帮我解决这个问题。
public ThreadLocal<WebDriver> m_driverForThread = new ThreadLocal<WebDriver>() {
@Override
protected WebDriver initialValue() {
WebDriver driver = null;
driver = loadDesktopDriver();
return driver;
}
};
protected static WebDriver loadDesktopDriver() throws Exception {
WebDriver driver = null;
driver = getNewDriver(m_browser, "", "", m_context);
return driver;
}
@SuppressWarnings("unchecked")
public static WebDriver getNewDriver(String browserName, String browserVersion, String platform,
ITestContext context) {
switch (driverType) {
case CHROME:
return new RemoteWebDriver(new URL(m_gridUrl), desiredCapabilities);
}
}
答案 0 :(得分:0)
这里有几件事:
a)您在suite.xml中缺少thread-count属性。
b)运行测试后,浏览器无法重新进入池中。所以你必须相应地启动你的集线器和节点
c)可以在这里添加完整的异常消息。