我正在使用 Selenium 从客户端自动执行服务器中的浏览器,但我希望服务器在启动时自动执行 selenium。
我在 /etc/init 中有 3 个文件:
代理服务器.conf:
respawn
start on runlevel [23]
script
exec java -jar selenium-server-standalone-2.20.0.jar -role hub -port 1111
end script
proxyserver2.conf和proxyserver3.conf是同一件事,只改变“脚本”的内容:
exec java -Dwebdriver.chrome.driver=/home/marco/selenium-client/chromedriver -jar selenium-server-standalone-2.20.0.jar -role node -port 2222 -hub http://192.168.1.12:1111 -browserName=chrome,maxInstances=5
如果我在启动时使用此方法执行此命令,当我在客户端上执行 Selenium 时,它会给我这个错误:
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
但是,如果我在终端中执行我在 /etc/init 中使用的相同命令,则一切正常……为什么?!
最后一件事,如果我执行:
ps aux | grep selenium
当服务器在启动时提供脚本时,它给了我:
root 746 0.0 12.1 677080 124468 ? Ssl Apr23 8:10 java -Dwebdriver...
root 749 0.0 12.7 685552 130280 ? Ssl Apr23 8.09 java -Dwebdriver...
root 755 0.0 1.9 680168 20240 ? Ssl Apr23 8.08 java -jar selenium...
当我在终端执行时,它给了我:
1000 9764 6.6 3.0 679236 30992 pts/0 Sl+ 10.33 0:01 java -jar...
1000 9783 14.0 3.0 677112 31752 pts/1 Sl+ 10.33 0:01 java -Dwebdriver...
1000 9792 12.6 3.0 675472 30944 pts/2 Sl+ 10.34 0:01 java -Dwebdriver...
为什么它不能工作?
谢谢!!