Can't use chrome driver for Selenium

后端 未结 12 1160
鱼传尺愫
鱼传尺愫 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 04:10

    Just place the chromedriver.exe in your python folder (in my case: C:\Python27) and use the below mentioned code it will work for you guys

    driver = webdriver.Chrome()
    driver.maximize_window()
    driver.get("URL")
    
    0 讨论(0)
  • 2020-12-01 04:16


    For Linux

    1. Check you have installed latest version of chrome browser-> "chromium-browser -version"
    2. If not, install latest version of chrome "sudo apt-get install chromium-browser"
    3. Get the appropriate version of chrome driver from http://chromedriver.storage.googleapis.com/index.html
    4. Unzip the chromedriver.zip
    5. Move the file to /usr/bin directory sudo mv chromedriver /usr/bin
    6. Goto /usr/bin directory and you would need to run something like "chmod a+x chromedriver" to mark it executable.
    7. finally you can execute the code.

    from selenium import webdriver
    driver = webdriver.Chrome()
    driver.get("http://www.google.com")
    display.stop()
    
    0 讨论(0)
  • 2020-12-01 04:18

    You should specify the executable file path, not the directory path that contains the executable.

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

    This code doesn't need path to drive file:

        from selenium import webdriver
        from webdriver_manager.chrome import ChromeDriverManager
    
        driver = webdriver.Chrome(ChromeDriverManager().install())
    
    0 讨论(0)
  • 2020-12-01 04:23

    Chrome

    import os   
    from selenium import webdriver
    chromedriver = "C://chromedriver.exe"                                                                     
    os.environ["webdriver.chrome.driver"] = chromedriver                      
    driver =webdriver.Chrome(chromedriver)
    
    0 讨论(0)
  • 2020-12-01 04:26

    For Debian/Ubuntu - it works:

    install Google Chrome for Debian/Ubuntu:

    sudo apt-get install libxss1 libappindicator1 libindicator7
    wget https://dl.google.com/linux/direct/google-chrome-
    stable_current_amd64.deb
    
    sudo dpkg -i google-chrome*.deb
    sudo apt-get install -f
    

    Install ChromeDriver:

    wget -N http://chromedriver.storage.googleapis.com/2.26/chromedriver_linux64.zip
    unzip chromedriver_linux64.zip
    chmod +x chromedriver
    
    sudo mv -f chromedriver /usr/local/share/chromedriver
    sudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver
    sudo ln -s /usr/local/share/chromedriver /usr/bin/chromedriver
    

    Install Selenium:

    pip install -U selenium
    

    Selenium in Python:

    from selenium import webdriver
    
    driver = webdriver.Chrome()
    driver.get('https://www.google.co.in/')
    
    0 讨论(0)
提交回复
热议问题