We are using Python robot framework automation. Is it possible to download and install edge driver automatically while script run based on the version passed as parameter?We are using selenium 3.14 , robot framework selenium library 4.5.0 and python 3.7
CodePudding user response:
No, that is not possible. Installation of any webdriver must be done before running tests, because it requires to have prepared the environment variable PATH and proper execution permissions for the webdriver.
CodePudding user response:
Is it possible to download and install edge driver automatically while script run based on the version passed as parameter?
Answer- YES
For that you need to install driver manager using - pip install webdriver-manager
Then use the below imports -
from selenium import webdriver
from webdriver_manager.microsoft import EdgeChromiumDriverManager
You can use the python function as keyword in robot framework something like given below. Where 96.0.1054.43
parameter is the version of edge driver. And this function is written in lets say - drivermanager.py
file.
def get_chromedriver_path():
driver_path = EdgeChromiumDriverManager("96.0.1054.43").install()
print(driver_path)
return driver_path
You can import this(drivermanager.py
) library in your testsuite using command - Library drivermanager.py
. This function will be treated as keyword when executed.
Testsuite will have testcase as
Open Chrome Browser
[Documentation] To create chrome browser instance with specific profile
${chromedriver_path}= drivermanager.Get Chromedriver Path
Here ${chromedriver_path}
variable holds the driver path. and the driver stored in the cache.
Screenshot of Executions -
References - 1. https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ 2. https://github.com/SergeyPirogov/webdriver_manager