我在 ubuntu 服务器中运行 selenium 测试用例,该服务器基本上在 firefox 和 chrome 中运行测试用例。Firefox 启动并成功运行测试用例,但 chrome 抛出异常:
*****下面是堆栈跟踪的片段:*****
在端口 21549 上启动 ChromeDriver (v2.8.240825)
PAC 支持被禁用,因为没有系统实现
测试 IntegrationTest.AdminUserelementscheck 失败:
org.openqa.selenium.WebDriverException:chrome 无法访问(驱动程序信息:chromedriver=2.8.240825,platform=Linux 2.6.32-431.el6.x86_64 x86_64)(警告:服务器未提供任何堆栈跟踪信息)[错误]命令持续时间或超时:20.83 秒
嗨下面是我的代码的一小段:
public class IntegrationTest {
private static final String configFile="test.properties";
private final String FIREFOX="firefox";
private final String CHROME="chrome";
private final String PHANTOMJS="phantomjs";
private final String BROWSERNAME="browser";
private static Properties props = new Properties();
public WebDriver webDriver;
private static Configuration additionalConfigurations;
@BeforeClass
public static void setUp() throws IOException, SQLException{
props.load(IntegrationTest.class.getResourceAsStream("/" + configFile));
}
@test
public void AdminUserelementscheck() throws SQLException, IOException {
String[] browsers = props.getProperty(BROWSERNAME).split(",");
System.out.println("Number of browsers specified in conf:"+props.getProperty(BROWSERNAME));
for(String browser:browsers){
System.out.println("Browser currently processing:"+browser);
if(browser.equalsIgnoreCase(FIREFOX))
webDriver = new FirefoxDriver();
else if(browser.equalsIgnoreCase(CHROME))
webDriver = new ChromeDriver();
else
webDriver = new PhantomJSDriver();
running(testServer(3333,fakeApplication()),webDriver, new Callback<TestBrowser>() {
********* LOGIN AND ASSERTION STATMENTS*******************
browser.quit()
}
});
}