尝试在Selenium Grid上设置phantomjs节点时遇到错误(https://wiki.jenkins-ci.org/display/JENKINS/Selenium+Plugin)
我已经设置了以下自定义json配置:
{
"capabilities": [
{
"browserName": "phantomjs",
"phantomjs.binary.path": "/usr/bin/phantomjs",
"platform": "LINUX",
"maxInstances": 5
}
],
"configuration": {
"nodeTimeout":120,
"port":5555,
"hubPort":4444,
"hubHost":"localhost",
"nodePolling":2000,
"registerCycle":10000,
"register":true,
"cleanUpCycle":2000,
"timeout":30000,
"maxSession":1
}
}
但是当我对它运行webdriver时出现错误:
WebDriverException: Message: The path to the driver executable must be set by the phantomjs.binary.path capability/system property/PATH variable; for more information, see https://github.com/ariya/phantomjs/wiki. The latest version can be downloaded from http://phantomjs.org/download.html
Stacktrace:
at com.google.common.base.Preconditions.checkState (Preconditions.java:199)
at org.openqa.selenium.phantomjs.PhantomJSDriverService.findPhantomJS (PhantomJSDriverService.java:236)
at org.openqa.selenium.phantomjs.PhantomJSDriverService.createDefaultService (PhantomJSDriverService.java:181)
at org.openqa.selenium.phantomjs.PhantomJSDriver.<init> (PhantomJSDriver.java:104)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0 (NativeConstructorAccessorImpl.java:-2)
at sun.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance (Constructor.java:526)
at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor (DefaultDriverProvider.java:103)
at org.openqa.selenium.remote.server.DefaultDriverProvider.newInstance (DefaultDriverProvider.java:97)
at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance (DefaultDriverFactory.java:60)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call (DefaultSession.java:222)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call (DefaultSession.java:1)
at java.util.concurrent.FutureTask.run (FutureTask.java:262)
at org.openqa.selenium.remote.server.DefaultSession$1.run (DefaultSession.java:176)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:615)
at java.lang.Thread.run (Thread.java:745)
-------------------- >> begin captured logging << --------------------
selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:4444/wd/hub/session {"desiredCapabilities": {"browserName": "phantomjs"}}
selenium.webdriver.remote.remote_connection: DEBUG: Finished Request
如果我停止插件启动的节点(并保持插件集线器运行),并按如下方式手动运行我自己的节点,它可以正常工作:
java -jar selenium-server-standalone-2.53.0.jar -role webdriver
-browser browserName=phantomjs,platform=LINUX
-hub http://localhost:4444/grid/register
[edit] phantomjs可以从shell执行,并且位于/ usr / bin / phantomjs:
$ whereis phantomjs
phantomjs: /usr/bin/phantomjs
我无法在线找到phantomjs设置的规范描述,这不是该插件提供的默认浏览器选项之一。
以上问题是/usr/bin/phantomjs
上的操作系统权限;我需要对其进行chmod a+x
。
诙谐地添加此额外问题
这有效(由我手动启动):
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.111.x86_64/jre/bin/java -jar /var/lib/jenkins/selenium-server-standalone-2.53.0.jar -role webdriver -browser browserName=phantomjs,platform=LINUX -hub http://localhost:4444/grid/register
这不是(由selenium插件启动的过程):
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.111.x86_64/jre/bin/java -cp /var/cache/jenkins/war/WEB-INF/lib/remoting-2.56.jar hudson.remoting.Launcher -cp /var/lib/jenkins/selenium-server-standalone-2.53.0.jar:/var/lib/jenkins/htmlunit-driver-standalone-2.20.jar -connectTo localhost:36322
运行测试时遇到的错误:
PHPUnit_Extensions_Selenium2TestCase_WebDriverException: The process has not exited yet therefore no result is available
答案 0 :(得分:3)
添加答案以防有人错过评论。
请检查phantomjs是否对所有用户都有'x'(执行)访问权限。如果没有,则使用该命令更改访问权限。
chmod +x /usr/bin/phantomjs
新错误“此过程尚未退出,因此无法获得结果”主要是硒/驱动程序版本不匹配。您可以尝试降级硒的版本。
顺便说一句,您使用的是什么版本的幻影。
答案 1 :(得分:0)
尝试将<div>This one stretches out:</div>
<div class="incorrect">
<img src="http://placehold.it/150x50" />
</div>
<div>This will preserve aspect ratio and look right:</div>
<div class="correct">
<img src="http://placehold.it/150x50" />
</div>
添加到Jenkins的Java标记中(通常查看-Dphantomjs.binary.path=/usr/bin/phantomjs
或/etc/default/jenkins
)。
答案 2 :(得分:0)
juste在命令行中添加路径,如下所示:
'/usr/bin/java' -Dphantomjs.binary.path='/home/john/.local/share/binman_phantomjs/linux64/2.1.1/phantomjs-2.1.1-linux-x86_64/bin/phantomjs' -jar '/home/john/.local/share/binman_seleniumserver/generic/3.0.1/selenium-server-standalone-3.0.1.jar'