skip to Main Content

I have just installed Selenium Runner on my Mac (Mojave) but I will also later be running it on CentOS 7. Is there any way I can tell my process the path of the chromedriver when I run it from a command line? Currently, I’m running it like so …

/usr/local/bin/selenium-side-runner /tmp/0ba4e59f-53d5-43ff-b7ff-127499868cf3.side

but getting this error

  ● Test suite failed to run

    The ChromeDriver could not be found on the current PATH. Please download the latest version of the ChromeDriver from http://chromedriver.storage.googleapis.com/index.html and ensure it can be found on your PATH.

After reading the insturxctions here — https://www.seleniumhq.org/selenium-ide/docs/en/introduction/command-line-runner/ , there is much talk about adding the path to the driver in the PATH environment variable. However, I’m running my script from a separate process that’ deson’t have access to my PATH, so I’d like a bit more control over how to tell Selnium Runner where the driver is.

Edit: Using Tarun’s solution I get the following strange result …

localhost:selenium davea$ selenium-side-runner  -c "chromeOptions.binary='/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'" myTestFile.side
info:    Running myTestFile.side
 FAIL  ./DefaultSuite.test.js
  ● Test suite failed to run

    TypeError: Target browser must be a string, but is <undefined>; did you forget to call forBrowser()?

Edit 2:

Contents of my “.side.yml” file and path to chromedriver …

localhost:selenium davea$ cat .side.yml 
capabilities:
  browserName: 'chrome'
  chromeOptions:
    binary: '/Users/davea/Documents/workspace/starter_project/selenium/chromedriver_mac'
  firefoxOptions:
    binary: '/Users/davea/Documents/workspace/starter_project/selenium/geckodriver_mac'

localhost:selenium davea$ ls -al /Users/davea/Documents/workspace/starter_project/selenium/chromedriver_mac
-rwxr-xr-x 1 davea staff 14994520 Jun 11 19:42 /Users/davea/Documents/workspace/starter_project/selenium/chromedriver_mac

Yet I still get the same result complaining about driver can’t be found …

localhost:selenium davea$ selenium-side-runner myTestSpike.side 
info:    Running myTestSpike.side
 FAIL  ./DefaultSuite.test.js
  ● Test suite failed to run

    The ChromeDriver could not be found on the current PATH. Please download the latest version of the ChromeDriver from http://chromedriver.storage.googleapis.com/index.html and ensure it can be found on your PATH.

3

Answers


  1. If you see their readme they do specify how to do the same

    https://www.npmjs.com/package/selenium-side-runner

    selenium-side-runner -c "chromeOptions.binary='/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'"
    

    You can even create a .side.yml and save the options there

    capabilities:
      browserName: 'chrome'
      chromeOptions:
        binary: '/path/to/chromedriver'
    

    See my updates in the another question related to this

    How do I run my selenium-side-runner to execute my test against Firefox?

    Login or Signup to reply.
  2. If you are running in a shell you can set an env variable which will be passed into the process your run. So just do this:

    env "webdriver.chrome.driver=/path/to/chromedriver" /usr/local/bin/selenium-side-runner /tmp/0ba4e59f-53d5-43ff-b7ff-127499868cf3.side
    
    Login or Signup to reply.
  3. You can try ChromeOptions class. You can create an instance of ChromeOptions, which has convenient methods for setting ChromeDriver-specific capabilities.

    // Create ChromeOptions instance
    ChromeOptions options = new ChromeOptions();
    
    // Set your custom path of the chrome driver to the options
    options.setBinary("/path/to/chrome/binary");
    
    // Pass the options object to the ChromeDriver instance
    ChromeDriver driver = new ChromeDriver(options);
    

    Since Selenium version 3.6.0, the ChromeOptions class in Java also implements the Capabilities interface, allowing you to specify other WebDriver capabilities not specific to ChromeDriver.

    ChromeOptions options = new ChromeOptions();
    // Add the WebDriver proxy capability.
    Proxy proxy = new Proxy();
    proxy.setHttpProxy("myhttpproxy:3337");
    options.setCapability("proxy", proxy);
    
    // Add a ChromeDriver-specific capability.
    options.addExtensions(new File("/path/to/extension.crx"));
    ChromeDriver driver = new ChromeDriver(options);
    

    Please go through this link for much more options Capabilities & ChromeOptions

    Refer this link Command line runner.

    Chrome specific capabilities
    If you have Chrome installed in a non-standard location on your machine you can specify the path so ChromeDriver knows where to look.

    selenium-side-runner -c "chromeOptions.binary='/path/to/non-standard/Chrome/install'"
    

    With Chrome specific capabilities you can also run the tests headlessly.

    selenium-side-runner -c "chromeOptions.args=[disable-infobars, headless]"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search