0

I am facing an unusual error while my selenium script tries to run automation tests by connecting to node which has been started using crontab (as shown below)

@reboot sh /home/selenium/automation/nodeStartUp.sh &

The nodeStartUp.sh content is shown below:

#!/bin/bash
java -jar /home/selenium/automation/selenium-server-standalone-3.0.0-beta3.jar -role node -nodeConfig /home/selenium/automation/node.json -log /home/selenium/automation/node.log

The error shown is as below: (Note: This error does not appear when I start the script manually and execute the testcases)

09:25:08.919 INFO [20] org.openqa.grid.internal.utils.SelfRegisteringRemote - Registering the node to the hub: http://XXX.XXX.XXX.XXX:4444/grid/register
09:25:08.940 INFO [20] org.openqa.grid.internal.utils.SelfRegisteringRemote - The node is registered to the hub and ready to use
09:25:10.972 INFO [17] org.openqa.selenium.remote.server.DriverServlet - Executing: [new session: Capabilities [{browserName=chrome, version=, platform=ANY}]])
09:25:10.972 INFO [28] org.openqa.selenium.remote.server.DefaultDriverProvider - Creating a new session for Capabilities [{browserName=chrome, version=, platform=ANY}]
09:25:10.973 WARN [17] org.openqa.selenium.remote.server.DriverServlet - Exception thrown
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '3.0.0-beta3', revision: 'c7b525d', time: '2016-09-01 14:57:03 -0700'
System info: host: 'BLR-SOFT-195', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-96-generic', java.version: '1.8.0_101'
Driver info: driver.version: unknown
        at java.util.concurrent.FutureTask.report(FutureTask.java:122)
        at java.util.concurrent.FutureTask.get(FutureTask.java:192)
        at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:183)
        at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSession.java:119)
        at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:95)
        at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:124)
        at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:59)
        at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:36)
        at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:111)
        at org.openqa.selenium.remote.server.JsonHttpCommandHandler.handleRequest(JsonHttpCommandHandler.java:185)
        at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverServlet.java:204)
        at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.java:166)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
        at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet.java:132)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
        at org.seleniumhq.jetty9.servlet.ServletHolder.handle(ServletHolder.java:808)
        at org.seleniumhq.jetty9.servlet.ServletHandler.doHandle(ServletHandler.java:587)
        at org.seleniumhq.jetty9.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
        at org.seleniumhq.jetty9.servlet.ServletHandler.doScope(ServletHandler.java:515)
        at org.seleniumhq.jetty9.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
        at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
        at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
        at org.seleniumhq.jetty9.server.Server.handle(Server.java:499)
        at org.seleniumhq.jetty9.server.HttpChannel.handle(HttpChannel.java:310)
        at org.seleniumhq.jetty9.server.HttpConnection.onFillable(HttpConnection.java:257)
        at org.seleniumhq.jetty9.io.AbstractConnection$2.run(AbstractConnection.java:540)
        at org.seleniumhq.jetty9.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
        at org.seleniumhq.jetty9.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '3.0.0-beta3', revision: 'c7b525d', time: '2016-09-01 14:57:03 -0700'
System info: host: 'BLR-SOFT-195', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-96-generic', java.version: '1.8.0_101'
Driver info: driver.version: unknown
        at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:113)
        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:209)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        ... 1 more
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:103)
        ... 9 more
Caused by: java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
        at com.google.common.base.Preconditions.checkState(Preconditions.java:199)
        at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109)
        at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:32)
        at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:137)
        at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
        at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)
        at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:138)
        ... 14 more
09:25:10.974 WARN [17] org.openqa.selenium.remote.server.DriverServlet - Exception: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html

Any help appreciated.

Prakash P
  • 419
  • 1
  • 8
  • 18

1 Answers1

1

It seems a problem related to chromedriver.

The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html

Where is your chromedriver located?

Which SO are you working in? Centos? Ubuntu? I recommend you to not run it in a cron. Instead you can create a service and see if it works:

Create a file in /etc/systemd/system/selenium-node.service

Add to the file:

[Unit]
Description=Run a selenium node

[Service]
ExecStart=/usr/bin/java -jar /route/to/selenium/selenium-server-standalone-2.52.0.jar -role node blablabla
Restart=on-abort

[Install]
WantedBy=multi-user.target

And run:

sudo systemctl daemon-reload
sudo systemctl start selenium-node.service

Or you can add sh /home/selenium/automation/nodeStartUp.sh at the end of the init.d file (but thats not the best option too).

Eje
  • 354
  • 4
  • 8
XorX
  • 238
  • 2
  • 5
  • 19
  • I removed the cron job just mins after posting this. I then created a file called "selenium.conf" and placed it under ~/.config/upstart. The contents of the file is as below: – Prakash P Sep 30 '16 at 10:14
  • `start on startup` `task` `exec – Prakash P Sep 30 '16 at 10:16
  • But will try your solution. I am trying it on Ubuntu. I am actually providing the webdriver.chrome.driver option in node.config file. As I mentioned everything is working fine if I open the terminal and run the command manually. Even with upstart it is not working. – Prakash P Sep 30 '16 at 10:19
  • Where is your chromedriver located? In /home/selenium/automation/? What is the route specified in the json file for the chromedriver? – XorX Sep 30 '16 at 10:42
  • { "browserName": "chrome", "maxInstances": 3, "platform": "ANY", "webdriver.chrome.driver": "/usr/bin/google-chrome" } – Prakash P Sep 30 '16 at 10:53
  • /usr/bin/google-chrome? did you changed the name? (only to know) https://groups.google.com/forum/#!topic/webdriver/mQsCIhPy3Jc – XorX Sep 30 '16 at 12:12
  • You can't define the chromedriver inside the json file. – XorX Sep 30 '16 at 12:12
  • Take a look at that link and the one I've post two comments ago. http://stackoverflow.com/questions/29013534/selenium-grid-with-chrome-driver-webdriverexception-the-path-to-the-driver-exe ;) – XorX Sep 30 '16 at 12:17
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/124642/discussion-between-prakash-p-and-jordi-giros-guerrero). – Prakash P Sep 30 '16 at 12:25