問題描述
我們有一個(gè) Ubuntu 服務(wù)器,用于在 Chrome 和 Firefox 上運(yùn)行 Selenium 測(cè)試(我安裝了 ChromeDriver),我還想在我的 Windows 10 計(jì)算機(jī)上本地運(yùn)行測(cè)試.我想保持兩臺(tái)計(jì)算機(jī)的 Python 代碼相同.但我沒有找到如何在 Windows 10 上安裝 ChromeDriver?我在文檔中沒有找到它 [1, 2].
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].
這是在 Chrome 中運(yùn)行測(cè)試的代碼:
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)
...
我還發(fā)現(xiàn)了 如何在中運(yùn)行 Selenium WebDriver 測(cè)試用例Chrome?但它似乎不在Python中(沒有標(biāo)記任何編程語(yǔ)言,它是什么?)
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?)
更新 #1: 我在 https://sites.google.com/a/chromium.org/chromedriver/getting-started,但是如果我想為兩者保留相同的 Python 代碼,我應(yīng)該將文件放在 Windows 10 的哪個(gè)位置電腦?
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?
更新 #2: 我下載了 chromedriver.exe
并將其放在 C:Windows
中,它可以工作,但我沒有看到它記錄在任何地方.
Update #2: I downloaded and put chromedriver.exe
in C:Windows
and it works, but I didn't see it documented anywhere.
推薦答案
正如 Uri 在問題中所說,在 Update #2 下,下載最新版本的 chromedriver 并將其放置在 C:Windows糾正問題.
As Uri stated in the question, under Update #2, downloading the latest release of chromedriver and placing it in C:Windows corrects the issue.
當(dāng)瀏覽器窗口打開(以及命令提示符窗口)時(shí),Chrome 掛起時(shí)遇到了同樣的問題.
I had the same issue with Chrome hanging when the browser window opens (alongside a command prompt window).
可以在以下位置找到最新的驅(qū)動(dòng)程序:
The latest drivers can be found at:
https://sites.google.com/a/chromium.org/chromedriver/下載
chromedriver_win32.zip 文件中的版本在我的 64 位系統(tǒng)上運(yùn)行.
The version in the chromedriver_win32.zip file is working on my 64-bit system.
這篇關(guān)于如何在 Windows 10 上安裝 ChromeDriver 并使用 Chrome 運(yùn)行 Selenium 測(cè)試?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!