Robot Framework can't find chromedriver in PATH variable - automation

I want to use Chrome for automation test with Robot Framework. Here are my settings:
*User variables:*
name: webdriver.chrome.driver
value: C:\chromedriver_win32\chromedriver.exe
name: PATH
values: ......;C:\chromedriver_win32\chromedriver.exe
My code:
*** Settings ***
Library BuiltIn
Library Selenium2Library
Library SikuliLibrary
Library OperatingSystem
*** Variables ***
${HOST} = VM
${URL} = http://VM.com
${BROWSER} = Chrome
*** Test Cases ***
Begin Web Test
Open Browser ${URL} ${BROWSER}
maximize browser window
After execution of command: pybot test.robot:
==============================================================================
[ WARN ] Keyword 'Capture Page Screenshot' could not be run on failure: No brows
er is open
Test Case FException
AttributeError: "'Service' object has no attribute 'process'" in <bound method
Service.__del__ of <selenium.webdriver.chrome.service.Service object at 0x000000
0003670278>> ignored
Test Case | FAIL |
Setup failed:
WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Plea
se see https://sites.google.com/a/chromium.org/chromedriver/home
------------------------------------------------------------------------------
What is wrong here?
Thank you

"chromedriver' executable needs to be in PATH" means that the location of chromedriver needs to be in the path. In your case, path needs to be "...;C:\chromedriver_win32". PATH contains folders, not executables.

Download Chromedriver.exe from its official website, extract the .exe file and copy this .exe file in scripts folder of Python installation, e.g. C:\Python36\Scripts
After this, add this scripts path in Environment variable, as below:
and now execute your test case.

Related

While running robot framework scripts, getting error: default adapter failed

I'm getting errors while running below mentioned RF scripts. How can I resolve this issue, I don't see any problem with the chrome/web driver version. Please let me know
ERROR: bluetooth_adapter_winrt.cc:1072 Getting Default Adapter failed.
Chrome version: 91.0.4472.124
Chrome We driver: 91
IDE: Pycharm
Machine: VM
Library SeleniumLibrary
*** Test Cases ***
User must sign in to check out
[Documentation] This is some basic info about the test
[Tags] Smoke
open browser http://www.amazon.com chrome
Wait Until Page Contains Amazon
Input Text id=twotabsearchtextbox Ferrari 485
Click Button xpath =//input[#id='nav-search-submit-button']
Wait Until Page Contains results for "Ferrari 485
CLICK LINK xpath=//*[#id="n/3073871"]/span/a/span
Click Link xpath=//input[#id='add-to-cart-button']
Page Should Contain Element ap_signala_pagelet_title
Element Text Should Be ap_signala_pagelet_title sign In
close browser
*** Keywords ***

ValueError: Argument 'url' got value 'www.google.com' that cannot be converted to None in Ubuntu OS but not in windows

For this Test case i am getting below error "ValueError: Argument 'url' got value 'www.google.com' that cannot be converted to None." in Ubuntu OS but not in windows
*** Settings ***
Library SeleniumLibrary
Library OperatingSystem
*** Variables ***
${Browser} FF
*** Test Cases ***
Open_browser www.google.com ${Browser}
*** Settings ***
Library SeleniumLibrary
Library OperatingSystem
*** Variables ***
${Browser} FF
*** Test Cases ***
test
Open_browser https://www.google.com ${Browser}
your robot file itself is wrong , you should provide a test name and also provide https://
I have faced the same issue.
You need to setup again.
Uninstall Python, and IDE
Again install Python, Robot-Framework, and Selenium.
Set the Python path and web driver path
Now restart the System.
In My case, it is working fine by following these steps.

How to get/interact with element_locator on the internal page in chromium

I am building automation for the browser (from chromium kernel)
while locating element from some internal page such as: chrome://settings/
I can get xpath of "Autofill" by //[#id="autofill"]
But when I run the script by Robot framework, it said "Element with locator '//[#id="autofill"]' not found."
Here is the simple script:
*** Settings ***
Library SeleniumLibrary
*** Variables ***
*** Test Cases ***
Open URL in Google Chrome
Open browser chrome://settings/ chrome
Click Element //*[#id="autofill"]
*** Keywords ***
https://imgur.com/a/FAJoYji
Thank you so much!

Test Template with Robot Framework

I am attempting to utilize the Robot Framework Test Template function and have been experiencing a little difficulty.
My current Test consist of opening 5 different websites (declared as variables)
Here is my code:
*** Settings ***
Library Selenium2Library
Library OperatingSystem
Library String
Library Collections
Test Template Open URL
*** Variables ***
${URL1} http://montrealgazette.com/
${URL2} https://www.usatoday.com/
${URL3} http://www.foxnews.com/
${URL4} http://www.cnn.com/
${URL5} https://ca.reuters.com/
*** Test Cases ***
Validate Availability
${URL1}
${URL2}
${URL3}
${URL4}
${URL5}
*** Keywords ***
Open URL
[Arguments] ${URL}
Open Browser $[URL] Chrome
When I run this code, 5 separate blank browser windows are opened.If there is a better way to do this, please let me know.
Thanks in advance for the help!
You don't seem to have indented your test case's content, which could perhaps be the problem (after you've fixed the syntax error mentioned in Raj sattam's answer). That's pretty much the only mistake I can see. You'll want to do the same in your keyword's declaration as well.
*** Test Cases ***
Validate Availability
${URL1}
${URL2}
${URL3}
${URL4}
${URL5}
If that still doesn't fix it, instead of using the ** Settings ** section, you may try to declare the test case itself as a templated test case, like this:
*** Settings ***
Library Selenium2Library
Library OperatingSystem
Library String
Library Collections
*** Variables ***
${URL1} http://montrealgazette.com/
${URL2} https://www.usatoday.com/
${URL3} http://www.foxnews.com/
${URL4} http://www.cnn.com/
${URL5} https://ca.reuters.com/
*** Test Cases ***
Validate Availability
[Template] Open URL
${URL1}
${URL2}
${URL3}
${URL4}
${URL5}
*** Keywords ***
Open URL
[Arguments] ${URL}
Open Browser ${URL} Chrome
you can use Execute Javascript Keyword like:
*** Settings ***
Library Selenium2Library
Library OperatingSystem
Library String
Library Collections
Test Template Open URL
*** Variables ***
${URL1} http://montrealgazette.com/
${URL2} https://www.usatoday.com/
${URL3} http://www.foxnews.com/
${URL4} http://www.cnn.com/
${URL5} https://ca.reuters.com/
*** Test Cases ***
Validate Availability
Open URLs In New Tab ${URL1} ${URL2} ${URL3} ${URL4} ${URL5}
*** Keywords ***
Open URLs In New Tab
[Arguments] #{URL}
:FOR ${eachUrl} IN #{URL}
\ Execute Javascript window.open(${eachUrl},"_blank");
The only part you need to change is the * Keywords * section
*** Keywords ***
Open URL
[Arguments] ${URL}
Open Browser ${URL} Chrome
Instead of square brackets use braces

How to call list of variables from a resource file into Robot test?

I have 1000 URL names to send to robot test. So that I have planned to assign each URL to a variable called ${ URL1}, ${URL2}... etc. When I use this inside "test.robot" its working as expected.
But When I call these variables from resource file I am getting "resources.txt' is empty" error as shown in below logs.
[ WARN ] Imported resource file 'C:\Users\test\Desktop\IMPORTANT - Robot Fram
work - Final Project Data\URL\resources.txt' is empty.
==============================================================================
Url based apps test suite
==============================================================================
testcase1 | FAIL |
Variable '${URL1}' not found.
------------------------------------------------------------------------------
testcase2 | FAIL |
Variable '${URL2}' not found.
------------------------------------------------------------------------------
Url based apps test suite | FAIL |
2 critical tests, 0 passed, 2 failed
2 tests total, 0 passed, 2 failed
==============================================================================
resources.txt contents:
${URL1} http://www.4shared.com/
${URL2} http://depositfiles.com/
${URL3} https://www.gmail.com/
test.robot settings content:
*** Settings ***
Library Selenium2Library
Library SSHLibrary
Suite Teardown Close All Browsers
Resource resources.txt
Please help to me fix this issue.
Thanks in advance
Your resources.txt should start with the "variables" header:
*** Variables ***
${URL1} http://www.4shared.com/
${URL2} http://depositfiles.com/
${URL3} https://www.gmail.com/
See Resource file structure in the User Guide: "The higher-level structure of resource files is the same as that of test case files otherwise".