0

I'm using Selenium to automate a browser in a Server from a client, but I want that the server execute selenium automatically at the startup.

I have 3 files in /etc/init:

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.conf and proxyserver3.conf that are the same thing and change only the content of "script":

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

If I execute this commands at the startup with this method, when I execute Selenium on the Client, it give me this error:

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.

But if I execute in the terminal the same commands that I use in /etc/init, all works perfectly... why?!

One last thing, if I execute:

ps aux | grep selenium

when the server the scripts at the startup it gives me:

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

when I execute in the terminal it gives me:

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

Why it can't works?

thanks!!

Mark Design
  • 664
  • 1
  • 6
  • 24

1 Answers1

0

I have seen this error when the chromedriver path is wrong. If you see the RC console it should have the chromedriver not found error message.

The chromedriver environment property should be passed as parameter to selenium jar file.

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

should be changed to

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
A.J
  • 4,929
  • 2
  • 27
  • 36