硒及;PhantomJS错误[Java]
我们正在用黄瓜和硒进行功能测试。我们的前端应用程序基于主干网和木偶网。当我们使用Chrome驱动程序运行测试时,一切都很顺利。但是,当我们更改驱动程序并使用phantomjs时,会出现以下错误:硒及;PhantomJS错误[Java],java,selenium,testing,phantomjs,Java,Selenium,Testing,Phantomjs,我们正在用黄瓜和硒进行功能测试。我们的前端应用程序基于主干网和木偶网。当我们使用Chrome驱动程序运行测试时,一切都很顺利。但是,当我们更改驱动程序并使用phantomjs时,会出现以下错误: [INFO - 2016-05-25T07:29:25.974Z] GhostDriver - Main - running on port 25401 [INFO - 2016-05-25T07:29:26.585Z] Session [68fe2830-224a-11e6-8e2c-478b5c
[INFO - 2016-05-25T07:29:25.974Z] GhostDriver - Main - running on port 25401
[INFO - 2016-05-25T07:29:26.585Z] Session [68fe2830-224a-11e6-8e2c-478b5c72f5db] - page.settings - {"XSSAuditingEnabled":false,"javascriptCanCloseWindows":true,"javascriptCanOpenWindows":true,"javascriptEnabled":true,"loadImages":true,"localToRemoteUrlAccessEnabled":false,"userAgent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1","webSecurityEnabled":true}
[INFO - 2016-05-25T07:29:26.585Z] Session [68fe2830-224a-11e6-8e2c-478b5c72f5db] - page.customHeaders: - {}
[INFO - 2016-05-25T07:29:26.585Z] Session [68fe2830-224a-11e6-8e2c-478b5c72f5db] - Session.negotiatedCapabilities - {"browserName":"phantomjs","version":"2.1.1","driverName":"ghostdriver","driverVersion":"1.2.0","platform":"windows-7-32bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"noProxy":null,"socksUsername":null,"httpProxy":"ALC-1DT2L12:49367","ftpProxy":null,"socksPassword":null,"sslProxy":"ALC-1DT2L12:49367","proxyAutoconfigUrl":null,"proxyType":"MANUAL","class":"org.openqa.selenium.Proxy","autodetect":false,"hCode":1261368293,"socksProxy":null}}
[INFO - 2016-05-25T07:29:26.585Z] SessionManagerReqHand - _postNewSessionCommand - New Session Created: 68fe2830-224a-11e6-8e2c-478b5c72f5db
[ERROR - 2016-05-25T07:29:48.721Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1464161388706
phantomjs://platform/console++.js:263 in error
[ERROR - 2016-05-25T07:29:49.511Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1464161389489
我从phantomjs中截取了一个屏幕截图,截图是白色的。这就像phantomjs尝试加载登录url,但什么都没有显示
我们使用以下依赖项:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.48.2</version>
</dependency>
<dependency>
<groupId>com.codeborne</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>1.2.1</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
</exclusion>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
</exclusion>
</exclusions>
</dependency>
提前感谢。好的,1.2.1是库版本,但是您使用的是哪个PhantomJS二进制版本?Windows的最新版本2.1.1
WebDriverWait espera = new WebDriverWait(getCurrentDriver(), 20);
espera.until(ExpectedConditions.elementToBeClickable(By.cssSelector("#userLogin")));