2012-05-02 195 views
0

我使用Selenium从客户端自动化服务器中的浏览器,但我希望服务器在启动时自动执行硒。在启动时执行Selenium

我在/ etc /初始化3个文件:

proxyserver.conf:

respawn 
start on runlevel [23] 
script 
    exec java -jar selenium-server-standalone-2.20.0.jar -role hub -port 1111 
end script 

proxyserver2.confproxyserver3.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 

如果我执行在用这种方法启动该命令,当我在客户机上执行硒,它给我这个错误:

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使用相同的命令/初始化,所有的作品完美...为什么?

最后一件事,如果我执行:

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... 

为什么它不能正常工作?

谢谢!!

回答

0

当chromedriver路径是错了,我已经看到了这个错误。如果你看到RC控制台它应有的chromedriver未找到错误消息。

的chromedriver环境属性应该作为参数传递给硒jar文件传递。

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 

应改为

exec java -jar selenium-server-standalone-2.20.0.jar -role node -port 2222 -hub http://192.168.1.12:1111 -browserName=chrome,maxInstances=5 -Dwebdriver.chrome.driver=/home/marco/selenium-client/chromedriver