Search code examples
seleniumselenium-webdriverrobotframeworkselenium2library

How to use Webdriver manager in Robot Framework?


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.


Solution

  • 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.