4

I am new to Robot framework and I have followed all set up related steps from this link, however, I am getting some error which I am not able to identify. Anybody, please help.

  *** Settings ***
  Documentation     Simple example using SeleniumLibrary.
  Library           Selenium2Library
  Library           OperatingSystem


  *** Variables ***
  ${LOGIN URL}      https://www.google.com/
  ${BROWSER}        Chrome
  ${EXECDIR}        C:\chromedriver_win32\chromedriver.exe


  *** Test Cases ***
  Checking browser to login page
  Setup chromedriver
  Open Browser To Login Page

  *** Keywords ***
  Open Browser To Login Page
  Open Browser    ${LOGIN URL}    ${BROWSER}


  Setup chromedriver
  Set Environment Variable  webdriver.chrome.driver  ${EXECDIR}

And here is the error I am getting

  C:\Users\sanat\AppData\Local\Programs\Python\Python36-32\Scripts\pybot.bat 
  Smoke.robot
  ======================================================================
  Smoke :: Simple example using SeleniumLibrary.                                

  =====================================================================
  Checking browser to login page                                 | FAIL |
  WebDriverException: Message: 'chromedriver' executable needs to be in 
  PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
 -------------------------------------------------------------------
 Smoke :: Simple example using SeleniumLibrar                      | FAIL |
 1 critical test, 0 passed, 1 failed
 1 test total, 0 passed, 1 failed
 ===============================================================
Output:  C:\Users\sanat\PycharmProjects\RobotFram\output.xml
Log:     C:\Users\sanat\PycharmProjects\RobotFram\log.html
Report:  C:\Users\sanat\PycharmProjects\RobotFram\report.html
C:\Users\sanat\AppData\Local\Programs\Python\Python36-32\lib\runpy.py:125: 
RuntimeWarning: 'robot.run' found in sys.modules after import of package 
'robot', but prior to execution of 'robot.run'; this may result in 
unpredictable behaviour
warn(RuntimeWarning(msg))

Process finished with exit code 1

My ChromeDriverPath is absolutely correct and I am using the latest version of chrome driver.

Adding one more point here: my Intellibot is also giving me compile time error for selenium keywords like 'Open Browser' which is I am not able to understand why? Installed robot and pycharm versions: Robot Framework 3.0.2 (Python 3.6.3 on win32)

Priyantha
  • 4,839
  • 6
  • 26
  • 46
Sanat
  • 267
  • 1
  • 5
  • 16
  • Please show a small code example which causes this error. – Code-Apprentice Nov 11 '17 at 16:37
  • 1
    As of now I have not written any custom library or code, they all are predefined keywords in the library. – Sanat Nov 11 '17 at 17:01
  • Have you done any research on the chromedriver error? There are many related questions on this site. Did you visit the URL in the error message and read through the "Getting Started" document? – Bryan Oakley Nov 11 '17 at 17:29

9 Answers9

8

As highlighted by Bryan Oakley, this is quite a common error and as such finding a solution for it shouldn't be too difficult. For this reason I'm not going to answer the obvious

"Chrome Driver is not in %PATH%" error.

In your script you tried to set a custom path to the ChromeDriver which is something that can be useful on occasions. You tried to set the environment variable webdriver.chrome.driver which does not work, because the Python binding does not check it for the chromedriver executable.

However, it is possible to provide the executable at the instantiation of the chromedriver. In Robot Framework SeleniumLibrary this is done using executable_path parameter. This then results in the following example:

Create Webdriver    Chrome    executable_path=C:/WebDrivers/chromedriver.exe
Go To    http://cnn.com
A. Kootstra
  • 6,827
  • 3
  • 20
  • 43
  • 1
    you should probably also mention that they way they used backslashes in the path will cause the path to be something other than what they expect. – Bryan Oakley Nov 12 '17 at 13:31
2

Got it, After doing some research, I found this:

For windows, chromedriver should be placed under /Python27/Scripts

and now its working fine, Thanks everyone

Sanat
  • 267
  • 1
  • 5
  • 16
2

This is the right solution

Create Webdriver    Chrome    executable_path=C:/WebDrivers/chromedriver.exe
Go To    http://cnn.com
U13-Forward
  • 69,221
  • 14
  • 89
  • 114
Rajesh D
  • 21
  • 1
0

Using the keyword Set Environment Variable can work. You can use the strings Path and path/to/folder that contains chromedriver.exe as parameters.

0

also make sure the name of the chrome driver is chromedriver.exe, renaming would cause issue in opening

Waterworks
  • 308
  • 4
  • 11
0

Use this hope it will work ...

*** Settings ***

Library Selenium2Library

*** Test Cases ***

Test2

 open browser    https://google.com     Chrome
0

If you are working with linux

  1. Download chrome driver if you havent.(https://chromedriver.chromium.org/home)

  2. Once downloaded, copy the driver into VENV of your current robot project.

  3. Now run.

This usually happens when you have not given the proper path of the chrome driver.

Timmy
  • 4,098
  • 2
  • 14
  • 34
0

Add chromedriver.exe in the path:

C:\Users\user_name\AppData\Local\Programs\Python\Python39
user3503711
  • 1,623
  • 1
  • 21
  • 32
-2

If you are looking to set it up for mac, then place the chrome driver in this path /usr/local/bin/{your chromedrive exe file}

Rakesh
  • 1
  • 1