Getting Chrome to launch via Selenium

前端 未结 6 1112
太阳男子
太阳男子 2020-12-29 06:01

Hi all I\'m very new to this and am having issues getting an instance of a Chrome browser from selenium in python. I\'m using Windows 8. I have downloaded the chromedriver b

相关标签:
6条回答
  • 2020-12-29 06:30

    I used the following and it worked! Thanks!

    driver = webdriver.Chrome(executable_path=r'C:\chromedriver.exe')
    #put your own path between the ''
    
    0 讨论(0)
  • 2020-12-29 06:32

    Assuming that your path is correct, make sure that you include the chromedriver itself: chromedriver.exe

    0 讨论(0)
  • 2020-12-29 06:35

    Update 2016

    The following solution works for me, with WebDriver 3.0.1, Chrome Driver 2.25.426923, Window 7

        System.setProperty("webdriver.chrome.driver","D:\\workspace\\chromedriver.exe");
        WebDriver driver;
        driver = new ChromeDriver();
    

    *Note:

    • Chrome Driver
    • See also: http://www.frontendtest.org/blog/path-executable-chrome/
    0 讨论(0)
  • 2020-12-29 06:43

    Two ways to set it, you somehow mixed up.

    • Put the chromedriver.exe's path into PATH (on Windows), so your PATH setting is correct, but you need to call the default constructor.

      driver = webdriver.Chrome()

    • Specify the path in webdriver.Chrome(executable_path='some path'). Here you need the full path to the executable, not the directory.

      webdriver.Chrome(executable_path=r'C:\Users\HaranKumar\Downloads\chromedriver_win32_2.0\chromedriver.exe')

    Choose either one you want.

    0 讨论(0)
  • 2020-12-29 06:50

    for python(selenium) you will need:

    from selenium import webdriver
    from selenium.webdriver import Chrome
    from selenium.webdriver.chrome.options import Options
    

    then put your chromedriver.exe path in. the "r" is just to prevent it from detecting the \ and causing errors in python

    PATH = r"C:\Program Files (x86)\chromedriver.exe"
    driver = webdriver.Chrome(PATH)
    options = webdriver.ChromeOptions()
    

    you can now order the driver to get websites

    driver.get('http://www.google.com')
    
    0 讨论(0)
  • 2020-12-29 06:56

    Even if you have chromedriver.exe in the PATH, its necessary to have chromedriver.exe in the folder where your executable scripts are present(atleast so is the case when it comes to python scripts)

    0 讨论(0)
提交回复
热议问题