Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
377 views
in Technique[技术] by (71.8m points)

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

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 computer. I want to keep the Python code the same for both computers. But I didn't find out how to install the ChromeDriver on Windows 10? I didn't find it on the documentation [1, 2].

Here is the code that runs the test in Chrome:

import unittest
from selenium import webdriver

class BaseSeleniumTestCase(unittest.TestCase):
    ...
    ...
    ...
    ...

    def start_selenium_webdriver(self, chrome_options=None):
        ...
        self.driver = webdriver.Chrome(chrome_options=chrome_options)
        ...

I also found How to run Selenium WebDriver test cases in Chrome? but it seems to be not in Python (no programming language is tagged, what is it?)

Update #1: I found some Python code in https://sites.google.com/a/chromium.org/chromedriver/getting-started, but where do I put the file in Windows 10 if I want to keep the same Python code for both computers?

Update #2: I downloaded and put chromedriver.exe in C:Windows and it works, but I didn't see it documented anywhere.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...