1

I want to use robotframework with Google Chrome. Somehow the chromedriver does not find the Google Chrome binary:

WebDriverException: Message: unknown error: cannot find Chrome binary

When I try to run my test with firefox, it works fine. I have search the net for some solutions, but I find only articles specifing the path to chromedriver, but not to the Google Chrome binary.

Heres what I have installed.

pybot --version
Robot Framework 3.0.4 (Python 3.5.4 on darwin)

Code to execute with pybot: google.robot

*** Settings ***
Documentation  Hello World for robotframwork with headless chrome
Library  SeleniumLibrary
#Library  OperatingSystem
#Suite Setup  Setup chromedriver
### https://stackoverflow.com/questions/28537290/how-to-set-path-chrome-driver-in-robot-framework

#*** Keywords ****
#Setup chromedriver
   #Set Environment Variable  webdriver.chrome.driver  /usr/local/bin/chromedriver
   #Set Environment Variable  webdriver.chrome.binary  /Applications/Chrome.app/Contents/MacOS/Google\ Chrome

*** Test Cases ***
User shall call google and make a screenshot
    [Documentation]  First test
    [Tags]  Headless
    #Open Browser  https://google.com  ff
    Open Browser  https://google.com  gc
    #Open Browser  https://google.com  headlesschrome
    Capture Page Screenshot
    Close All Browsers

When I run this code I get the following:

pybot google.robot
==============================================================================
Google :: Hello World for robotframwork with headless chrome
==============================================================================
User shall call google and make a screenshot :: First test            | FAIL |
WebDriverException: Message: unknown error: cannot find Chrome binary
  (Driver info: chromedriver=2.43.600229 (3fae4d0cda5334b4f533bede5a4787f7b832d052),platform=Mac OS X 10.11.6 x86_64)
------------------------------------------------------------------------------
Google :: Hello World for robotframwork with headless chrome          | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
==============================================================================
Output:  /Users/foo/workspace/robotframework/output.xml
Log:     /Users/foo/workspace/robotframework/log.html
Report:  /Users/foo/workspace/robotframework/report.html
jerik
  • 5,714
  • 8
  • 41
  • 80
  • Chrome at standard location? spaces in chrome path? – timbre timbre Oct 27 '18 at 01:15
  • If you're at a command prompt and type `chrome` and press return, does chrome start up? – Bryan Oakley Oct 27 '18 at 01:44
  • @BryanOakley what will it validate if chrome start up OR not after hitting command in chrome? – Dev Oct 27 '18 at 04:57
  • Check this discussion https://stackoverflow.com/questions/50138615/cannot-find-chrome-binary-with-selenium-in-python-for-older-versions-of-google-c – undetected Selenium Oct 27 '18 at 08:15
  • @DebanjanB the mentioned discussion does not describe how i use it in robotframework. Its nit clear to me where to integrate this hack. – jerik Oct 27 '18 at 09:42
  • 1
    @Dev - it will validate whether or not `chrome` is in your path. If it doesn't start up and instead throws an error, then it clearly isn't in your PATH. – Bryan Oakley Oct 27 '18 at 11:33
  • Under OSX Chrome is located under ``/Applications/Chrome.app/Contents/MacOS/Google Chrome``. I added the directory to the path and added alias ``chrome`` / ``Chrome`` for ``Google Chrome``. On my shell Chrome opens when I use the alias commands, but it does not work for my pybot test. Still the same error-message. Its feels a little bit strange to add an alias, so that the Standard Chrome installation can be accessed... Does it matter that I use zsh as shell? Where can I get the information, which locations chromedriver checks for the ``Chrome`` location? – jerik Oct 27 '18 at 16:48
  • 1
    There used to be a bug in selenium, it couldn't process path with spaces. Don't know if it was fixed (you can google it). But if that's the case, providing chrome binary path should help. Check this solution: https://stackoverflow.com/a/45503916/5318223 – timbre timbre Oct 27 '18 at 18:41
  • 1
    @jerik For information on _which locations chromedriver checks for the Chrome location_ check the discussions [In Selenium how does ChromeDriver executable finds Chrome browser?](https://stackoverflow.com/questions/52241845/in-selenium-how-does-chromedriver-executable-finds-chrome-browser) and [What is default location of ChromeDriver and for installing Chrome on Windows](https://stackoverflow.com/questions/49788257/what-is-default-location-of-chromedriver-and-for-installing-chrome-on-windows) – undetected Selenium Oct 27 '18 at 19:43
  • 1
    @DebanjanB perfect hint! I switched my Chrome location on the file system from ``/Applications/Chrome.app/Contents/MacOS/Google Chrome`` to ``/Applications/Google Chrome.app/Contents/MacOS/Google Chrome``. That did the trick. Now it runs like desired. Based on the information of [In Selenium how does ChromeDriver executable finds Chrome browser?](https://stackoverflow.com/a/52259166/1933185) > [Chromedriver Requirements](https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver#requirements) – jerik Oct 27 '18 at 19:57

1 Answers1

0

Based on @DebanjanB comment I found my solution.

The chromedriver searches for the Chrome Browser on OSX at

/Applications/Google Chrome.app/Contents/MacOS/Google Chrome

Chrome was installed on my OSX on:

/Applications/Chrome.app/Contents/MacOS/Google Chrome

On my filesystem I renamed Chrome.app to Google Chrome.app and from that point on it worked. For any other OS, see the Chromedriver Requirements

jerik
  • 5,714
  • 8
  • 41
  • 80