Search code examples
pythonpathsystem

Python/Webdriver: how do I add browser binaries to path when I do not have admin rights?


I need to make three exe files visible to Python by placing them in a location where Python can find them. Placing the files in the same folder with the .py file did not solve the problem

I have no admin rights on my laptop and I can not change the PATH (Windows 10 machine) neither can I place files in the folders where the PATH variable points to

what are my options to trick Python to find the files ?


Solution

  • In your answer above it looks like you've mixed up 2 solutions;

    Solution 1:

    chromedriver = "C:\\Utils\\WebDrivers\\chromedriver.exe"
    
    driver = webdriver.Chrome(chromedriver)
    
    browser.get('http://www.yahoo.com')
    

    Solution 2:

    chromedriver = "C:\\Utils\\WebDrivers\\chromedriver.exe"
    
    os.environ["webdriver.chrome.driver"] = chromedriver
    browser = webdriver.Chrome()
    browser.get('http://www.yahoo.com')
    

    In your solution you've called the constructor for the driver twice.

    Solution 1 will create the driver based on the executable location you explicitly provided in the constructor.

    Solution 2 will create the driver based on the environment variable for the executable.

    In your answer what will happen is you'll create 2 instances of Chrome, both are valid and won't throw an error, but it'll just be messy. You should really only call the driver constructor once.