0

Currently I'm downloading exe files manually and using for browser launch in Python Robot framework. I just want to upgrade it auto download using Webdriver Manager.

I tried below code but its downloaded and save it the path we configured in pip list [2nd line of code]. Instead of auto download in my local machine, I want to download directly into project directory because of few restriction issues in my organisation. Can anyone provide suggestions on this?

pip install webdrivermanager

webdrivermanager firefox chrome --linkpath /usr/local/bin

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

def get_chromedriver_path():
    driver_path = ChromeDriverManager().install()
    print(driver_path)
    return  driver_path

Library  chromedriversync.py

${chromedriver_path}=   chromedriversync.Get Chromedriver Path
Create Webdriver    chrome   executable_path=${chromedriver_path}
Go to  www.google.com
Pari
  • 19
  • 8
  • Is all of the code in that code block in a single file? If not, please attempt to fix the formatting so that it's clear what code is in what file. – Bryan Oakley Nov 19 '20 at 18:58
  • Tanks for your reply @BryanOakley and below code work out for me! – Pari Dec 02 '20 at 18:23
  • Does this answer your question? [How to auto download .exe files to project directory based on browser version using Webdriver Manager in Python Robotframework](https://stackoverflow.com/questions/64912715/how-to-auto-download-exe-files-to-project-directory-based-on-browser-version-us) – gore Oct 16 '21 at 07:39

1 Answers1

0

To download .exe files into current project directory, we can use os library as below, below code worked out as per requirement. Adding for other's reference,

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from lib2to3.tests.support import driver
import os
from os.path import curdir

def get_chromedriver_path():
    ReturnPath = os.getcwd()
    driver_path = ChromeDriverManager(path=ReturnPath).install()
    print(driver_path)
    return driver_path

   
Library    browser.py

    ${driver}=    browser.Get Chromedriver Path
    log    ${driver}  
    Create Webdriver    Chrome    executable_path=${driver}    chrome_options=${options}   

Pari
  • 19
  • 8