How do I install ChromeDriver on Windows 10 and run Selenium tests with Chrome?

前端 未结 3 1509
無奈伤痛
無奈伤痛 2021-02-02 12:15

We have an Ubuntu server which we use for running Selenium tests with Chrome and Firefox (I installed ChromeDriver) and I also want to run the tests locally on my Windows 10 com

相关标签:
3条回答
  • 2021-02-02 12:35

    As Uri stated in the question, under Update #2, downloading the latest release of chromedriver and placing it in C:\Windows corrects the issue.

    I had the same issue with Chrome hanging when the browser window opens (alongside a command prompt window).

    The latest drivers can be found at:

    https://sites.google.com/a/chromium.org/chromedriver/downloads

    The version in the chromedriver_win32.zip file is working on my 64-bit system.

    0 讨论(0)
  • 2021-02-02 12:41
    1. Download the chromedriver.exe and save it to a desired location
    2. Specify the executable_path to its saved path

    The sample code is below:

    from selenium import webdriver
    
    options = webdriver.ChromeOptions()
    options.add_argument('headless')
    driver = webdriver.Chrome(executable_path="path/to/chromedriver.exe", chrome_options=options)
    driver.get("example.html")
    # do something here...
    driver.close()
    

    As Uri stated in Update #2 of the question, if we put the chromedriver.exe under C:/Windows, then there is no need to specify executable_path since Python will search under C:/Windows.

    0 讨论(0)
  • 2021-02-02 12:49

    Let me brief out the requirements first. You need to download the chrome web driver zip from here. https://chromedriver.storage.googleapis.com/index.html?path=2.33/

    Extract the file and store it in a desired location.

    Create a new project in Eclipse and include the following code in your class.

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

    Explanation : System.setProperty(key,value):

    Key is default and same for all the systems, value is the location of your chromedriver extract file.

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