In selenium I used webdriver manager through a command:
driver = webdriver.Chrome(Chromedrivermanager().install())
Is there a webdriver manager use for the robot framework? I would like the webdriver manager to download automatically when running the test script without additional interference.
My solution for using this with Robot Framework was with a python library that I called chromedriversync.
chromedriversync.py:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
def get_chromedriver_path():
driver_path = ChromeDriverManager().install()
print(driver_path)
return driver_path
Then, in my robotframework tests, I add
Library chromedriversync.py
${chromedriver_path}= chromedriversync.Get Chromedriver Path
Create Webdriver chrome executable_path=${chromedriver_path}
Go to www.google.com
I just use the chromedrivermanager install method's returned path variable, to supply to the Open Browser Robot Framework keyword.
The only thing that i found in internet is that Youn need to install webdrivermanager with command :
pip install webdrivermanager
and you launch this command before your script:
webdrivermanager chrome
robot --outputdir ./results/Robot-results ./TestSuits/*
NB: your browser (Chrome) has to be updated too : (Ubuntu)
sudo apt-get update
sudo apt-get install google-chrome-stable
There are two web driver managers as shown below,
If you use this one, you need to do one additional step on the command line, you cannot proceed with the test code unless you execute the below command, as this is part of the webdrivermanager setup.
webdrivermanager -
webdrivermanager 0.7.4
command-line step -
webdrivermanager chrome:2.38 firefox opera:v.2.35
webdriver-manager 2.3.0
You need to do the following to use webdriver-manager, did you notice something, there is nothing which needs to be done anything specific to webdriver-manager, BEAUTY of making use of robotframework. nice!!!
code
1. pip install webdriver-manager robotframework robotframework-seleniumlibrary
(prjenv) 09:37 PM##~::>pip list
Package Version
------------------------------ ----------
certifi 2018.11.29
chardet 3.0.4
colorama 0.4.1
configparser 4.0.2
crayons 0.3.0
idna 2.8
pip 19.2.3
requests 2.22.0
robotframework 3.1.2
robotframework-seleniumlibrary 4.1.0
selenium 3.141.0
setuptools 40.8.0
urllib3 1.25.6
webdriver-manager 2.2.0
wheel 0.32.3
2. create a file sample.robot
***Settings***
Library SeleniumLibrary
***Test Cases***
Sample Webdriver
[Tags] wd0
[Documentation] Sample invocation using WD
Open Browser http://google.com ff
Close All Browsers
3. execute the file as follows
robot *.robot
Output
========
(prjenv) 09:38 PM##~::>robot *.robot
==============================================================================
Sam
==============================================================================
Sample Webdriver :: Sample invocation using WD | PASS |
------------------------------------------------------------------------------
Sam | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
Output: /Users/apachemain/output.xml
Log: /Users/apachemain/log.html
Report: /Users/apachemain/report.html
THAT'S IT!!!
in the cmd terminal
pip install webdrivermanager
webdrivermanager firefox chrome --linkpath /usr/yourdir
as for automatic updates you could make a batch file .bat (just cmd input) with the last command (it will update the version automatically) and set it to a windows scheduler
https://www.windowscentral.com/how-create-and-run-batch-file-windows-10
https://www.digitalcitizen.life/how-create-task-basic-task-wizard
Related
I have been trying to install selenium and webdriver in PyCharm without PIP and install package via Interpreter settings as both are blocked. Can someone please help?
Tried via pip in terminal and install package in interpreter but both didn't work
I am trying to create a simple robot framework test, but when i run the following code, the test fails saying that there's no keyword for 'open browser'. It looks like the selenium library is not recognized, but I cannot understand why, as I have the required plugins installed (intellibot and robotframework support)
*** Settings ***
Documentation Testing
Library SeleniumLibrary
Library AngularJSLibrary
*** Variables ***
${BROWSER} chrome
*** Test Cases ***
Testing
begin web test
*** Keywords ***
Begin web test
open browser about:blank ${BROWSER}
maximize browser window
It seems that the Selenium library is missing from Machine. Following step can be done.
In the command prompt :
run command : pip list
It should contain following library : robotframework-seleniumlibrary
If not then install : python -m pip install robotframework-seleniumlibrary
Also then the IDE can be checked with the Interpreter or venv list of packages added in the project has the robotframework-seleniumlibrary added.
Did you install robotframework-seleniumLibrary?? You can install by executing following command.
pip install --upgrade robotframework-seleniumlibrary
Official Page for reference: official robot framework selenium library documentation. Also you need to have chrome drivers installed Download Chrome Driver.
Getting the error while running the script.
session not created: This version of ChromeDriver only supports Chrome version 89
Current browser version is 91.0.4472.77
Looks like your ChromeDriver is outdated.
The latest stable release(ChromeDriver) is ChromeDriver 90.0.4430.24
Latest beta release: ChromeDriver 91.0.4472.19
Get it from here
If you are working with selenium using python then I would recommend a python package webdriver-manager. You can install it using pip : pip install webdriver-manager Once the package is installed, you won't need to specify the chromedriver path or download chromdriver.exe Just use the below lines in your script and the plugin will identify the version of chrome browser installed in your system:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(ChromeDriverManager().install())
driver.get("google.com")
I am trying to execute webdirver-manager update command. But chrome driver unzipping 85.0.4183.38 instead of 84.0.4147.89 as my chrome browser version is 84.0.4147.89.
I tried the following:
Webdriver-manager update --version.chrome=84.0.4147.89
a. Downgrading the driver for browser compatible version.
Uninstalling & reinstalling Chrome
Uninstalling & reinstalling chromedriver / protractor / webdriver
Webdriver-manager update --version.chrome 2.28
a. Downgrading the driver for browser version 54+
Still I am getting the error:
E/launcher - session not created: This version of ChromeDriver only supports Chrome version 85
Please help on this.
This isn't the usual case when you use Protractor. However as per the discussions in:
Protractor 7.0.0 only supports chrome verison 85, while chrome version is 85 (error)
webdriver-manager update downloads an incompatible version of chromedriver
As of now there seems to be some discrepancy in downloading the latest stable ChromeDriver. The ChromeDriver - WebDriver for Chrome repository clearly suggests:
Current stable release: ChromeDriver 84.0.4147.30
Current beta release: ChromeDriver 85.0.4183.38
So as the current google-chrome browser version is Version 84.0.4147.89, ChromeDriver 84.0.4147.30 should have been downloaded and installed.
Solution
As per #Fuun347's comment the solution is to:
Add version arguments to the webdriver-manager update and start commands. Updating and starting your webdriver with these commands will force the version to always be 84:
webdriver-manager update --versions.chrome=84.0.4147.30
webdriver-manager start --versions.chrome=84.0.4147.30
Note: Running ng e2e --project=e2e-no-serve --specs=./src/service/ --webdriverUpdate=false will stop the angular-cli from trying to update the webdriver.
Further, #TylerNielsen in his comment added:
The following worked for us:
We have webdriver-manager installed as project dependency.
we call webdriver-manager update --versions.chrome 84.0.4147.30 prior
to running our tests. This will install the 84 chromedriver version in
./node_modules/webdriver-manager/selenium/. (We just made this as a
npm script in our package.json)
We then update the protractor.conf file to have this line in the root
of exports.config:
chromeDriver:"./node_modules/webdriver-manager/selenium/chromedriver_84.0.4147.30.exe"**
Protractor still installs chromedriverr 85, but it will use the 84
version.
In our case, we run our protractor tests in docker, but develop mostly on windows. So I updated the protractor.conf to have this line
so that it works in either: chromeDriver: process.platform === "win32"
?
"./node_modules/webdriver-manager/selenium/chromedriver_84.0.4147.30.exe"
:
"./node_modules/webdriver-manager/selenium/chromedriver_84.0.4147.30"
Please re download chrome driver exe according to your browser version (https://chromedriver.chromium.org)Your browser versions are updating time to time so you need to use exact driver exe.
I am trying to use chrome standalone driver on Travis CI server. I am getting this error:
selenium.common.exceptions.WebDriverException: Message: u'chrome not reachable\
The script runs fine locally.
in .travis.yml I have
before_script:
# google chrome standalone driver
- wget http://chromedriver.storage.googleapis.com/2.10/chromedriver_linux64.zip
- unzip chromedriver_linux64.zip
- sudo mv chromedriver /usr/local/bin
- sudo chmod a+x /usr/local/bin/chromedriver
and in my tests I have
from selenium.webdriver import Chrome
from pyvirtualdisplay import Display
display = Display(visible=0, size=(800, 600))
display.start()
Chrome()
and after a delay I get the error message stated above.
I have tried changing the location of the chrome driver, and explicitly pass the executable_path to Chrome, but no joy.
I've successfully run tests in Travis using headless Chrome.
I've used the following arguments to start chrome:
no-sandbox
no-default-browser-check
no-first-run
disable-default-apps
The no-sandbox argument was the one that bypassed the 'chrome not reachable' error.