Can't use chrome driver for Selenium

后端 未结 12 1159
鱼传尺愫
鱼传尺愫 2020-12-01 03:57

I\'m having trouble using the Chrome driver for Selenium. I have the chromedriver downloaded and saved to C:\\Chrome:

driver = webdriver.Chrome(executable_pa         


        
相关标签:
12条回答
  • 2020-12-01 03:59

    For windows

    Download webdriver from:

    http://chromedriver.storage.googleapis.com/2.9/chromedriver_win32.zip

    Paste the chromedriver.exe file in "C:\Python27\Scripts" Folder.

    This should work now.

    from selenium import webdriver
    driver = webdriver.Chrome()
    
    0 讨论(0)
  • 2020-12-01 04:00

    When you call selenium or any testing automation library, you would need to add this the code here is in Python but this can be done in Java and Ruby as well.

    options = webdriver.ChromeOptions()
    options.binary_location = '/usr/bin/chromium-browser'
    #All the arguments added for chromium to work on selenium
    options.add_argument("--no-sandbox") #This make Chromium reachable
    options.add_argument("--no-default-browser-check") #Overrides default choices
    options.add_argument("--no-first-run")
    options.add_argument("--disable-default-apps") 
    driver = webdriver.Chrome('/home/travis/virtualenv/python2.7.9/chromedriver',chrome_options=options)
    
    0 讨论(0)
  • 2020-12-01 04:01
    import os
    from selenium import webdriver
    chromedriver = "C:\Drivers\chromedriver_win32\chromedriver.exe"
    os.environ["webdriver.chrome.driver"] = chromedriver
    driver =webdriver.Chrome(chromedriver)
    driver.get("https://www.facebook.com")
    print(driver.title)
    driver.close()
    
    0 讨论(0)
  • 2020-12-01 04:03

    For Windows with virtual workspace

    First, check your browser version: go to 3 dons most right corner of the chrome browser and click it, then, --> Help-->About Google Chrome

    once you identify our browser version, we have to download and install chrome drive from this link

    extract the zip folder and past chromedriver.exe file in C:\Users\name\virtual_workspace\Scripts

    from selenium import webdriver
    wbdriver = webdriver.Chrome()
    
    0 讨论(0)
  • 2020-12-01 04:05

    All you need to do is Paste the Chromedriver.exe in python36-32 folder.And you can use It Simply like:

    from selenium import webdriver
    driver = webdriver.Chrome()
    

    No need to paste path again and again.

    OR
    You can Use:

    driver = webdriver.Chrome(executable_path="C:/Chrome/chromedriver.exe")
    
    0 讨论(0)
  • 2020-12-01 04:06

    In addition to the selected answer (windows style path):

    driver = webdriver.Chrome(executable_path=r"C:\Chrome\chromedriver.exe")
    

    Note the r in front of the "C:\Chrome\chromedriver.exe", this makes this string a raw string.

    In case you do not want to use a raw string you should escape the slash like so \\, this would become:

    driver = webdriver.Chrome(executable_path="C:\\Chrome\\chromedriver.exe")
    

    Or you can replace the \ with a /, you will get this:

    driver = webdriver.Chrome(executable_path="C:/Chrome/chromedriver.exe")
    
    0 讨论(0)
提交回复
热议问题