我有以下问题
java -jar selenium-server-standalone-2.53.0.jar -role hub
phantomjs --webdriver=8090 --webdriver-selenium-grid-hub=http://localhost:4444
但得到错误:
[INFO - 2016-03-25T13:56:28.397Z] GhostDriver - Main - 正在运行 8090端口[INFO - 2016-03-25T13:56:28.397Z] GhostDriver - Main - 注册Selenium HUB' http://localhost:4444'版本:使用 ' 127.0.0.1:8090'同 org.openqa.grid.selenium.proxy.DefaultRemoteProxy作为远程代理。 [ERROR - 2016-03-25T13:56:28.400Z] GhostDriver - main.fail - {"线" 97" sourceURL":" phantomjs://platform/hub_register.js","堆栈":&#34 ;寄存器@ phantomjs://platform/hub_register.js:97:79 \ nglobal 代码@ phantomjs://code/main.js:78:37"}
phantomjs://platform/console++.js:263错误
标准节点工作正常,但PhantomJS失败了。我做错了什么?
答案 0 :(得分:5)
解决方法*** 来自phantomjs http://phantomjs.org/build.html的d / l源代码并在src / ghostdriver中编辑hub_register.js 注释掉如下所示的行:
// var ghostdriver = ghostdriver || {};
return {
capabilities: [{
browserName: "phantomjs",
version: version,
//platform: ghostdriver.system.os.name + '-' + ghostdriver.system.os.version + '-' + ghostdriver.system.os.architecture,
maxInstances: 1,
seleniumProtocol: "WebDriver"
编译,一切正常!
答案 1 :(得分:5)
对于任何仍在寻找的人,这里有linux和windows x64构建,其中包含v2.1.1的解决方法(Windows构建是一个拉取请求 - 十六进制编辑器解决方法不适用于Windows系统.exe' s压缩)
答案 2 :(得分:1)
尝试使用本地IP替换 localhost
phantomjs --webdriver=8090 --webdriver-selenium-grid-hub=http://localhost:4444
带
phantomjs --webdriver=8090 --webdriver-selenium-grid-hub=http://127.0.0.1:4444
答案 3 :(得分:1)
您可以使用dd
命令覆盖部分二进制文件
我将用platform:
替换//atform:
:
$ cp /usr/local/bin/phantomjs .
$ ./phantomjs --version
2.1.1
$ xxd -c 16 phantomjs | grep -C 2 'platform:'
01c6aaa0: 7273 696f 6e3a 2076 6572 7369 6f6e 2c0a rsion: version,.
01c6aab0: 2020 2020 2020 2020 2020 2020 2020 2020
01c6aac0: 706c 6174 666f 726d 3a20 6768 6f73 7464 platform: ghostd
01c6aad0: 7269 7665 722e 7379 7374 656d 2e6f 732e river.system.os.
01c6aae0: 6e61 6d65 202b 2027 2d27 202b 2067 686f name + '-' + gho
$ printf '//' | dd of=phantomjs conv=notrunc bs=1 seek=$((0x01c6aac0+0))
2+0 records in
2+0 records out
2 bytes transferred in 0.000117 secs (17085 bytes/sec)
$ xxd phantomjs | grep 'atform:'
01c6aac0: 2f2f 6174 666f 726d 3a20 6768 6f73 7464 //atform: ghostd
$ ./phantomjs --version
2.1.1
$ mv phantomjs /usr/local/bin/
如果找不到字符串,请尝试增加每行八位字节(xxd -c 256
)。
答案 4 :(得分:0)
我有同样的问题。而不是像Ojen G.所建议的那样下载源代码和编译,而是使用fix posted by neuro-sys来对可执行文件进行更改。我的操作系统是Ubuntu 16.04。
下载replacestrings.c program。
wget https://gist.githubusercontent.com/neuro-sys/3bf00b6cf28a93e07e44/raw/52f715fd49fbd271a9450b61d5cd3cf29907a5a0/replacestring.c
编译程序
gcc replacestring.c -o replacestring
用二进制替换Java源代码字符串,创建固定二进制文件。
./replacestring "$(strings /usr/lib/phantomjs/phantomjs | grep "platform: ghostdriver")" " " < /usr/lib/phantomjs/phantomjs > f_phantomjs
制作二进制可执行文件;并作为替代
chmod +x f_phantomjs
sudo chown root:root f_phantomjs
sudo mv f_phantomjs /usr/lib/phantomjs
cd /usr/lib/phantomjs
sudo echo "Fixed error in phantomjs; old file in e_phantomjs" > README.txt
sudo mv phantomjs e_phantomjs
sudo ln f_phantomjs phantomjs
完成这些步骤后,它运行正常(Selenium hub已经运行):
phantomjs --webdriver=8080 --webdriver-selenium-grid-hub=http://localhost:4444
[INFO - 2016-05-07T16:33:35.534Z] GhostDriver - Main - running on port 8080
[INFO - 2016-05-07T16:33:35.534Z] GhostDriver - Main - registering to Selenium HUB 'http://localhost:4444' version: using '127.0.0.1:8080' with org.openqa.grid.selenium.proxy.DefaultRemoteProxy as remote proxy.
[INFO - 2016-05-07T16:33:35.604Z] HUB Register - register - Registered with grid hub: http://localhost:4444/ (ok)
答案 5 :(得分:0)
遵循这个要点: https://gist.github.com/neuro-sys/41e368839a9b20dafb34
编辑二进制文件以将//
放在违规行前面,但不是字符串替换。
- &GT;请按照有关使用hdex
搜索platform:
并替换为//atform:
将pl
替换为//
(十六进制为2F2F
)
答案 6 :(得分:0)
我花了2个月试图解决这个问题,尝试一切可能,我的主要问题是很多解决方案都不会连接到网格,而那些做的是在docker容器中什么只能连接到托管的本地网格在同一个Docker主机上。
所以...我终于建立了自己的解决方案: https://github.com/madhavajay/selenium-node-phantomjs
Docker镜像是madhavajay / selenium-node-phantomjs
它使用PhantomJS 2.1.1自定义构建与固定Ghostdriver然后我自己调整到最新的Ghostdriver分支,以允许自定义--remoteHost参数全部包含在具有可配置环境变量的Docker容器中。
我希望这可以挽救我所遭受的失去的一周。