我们有一个 Ubuntu 服务器,用于在 Chrome 和 Firefox 上运行 Selenium 测试(我安装了 ChromeDriver),我还想在我的 Windows 10 计算机上本地运行测试.我想保持两台计算机的 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 中运行测试的代码:
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)
...
我还发现了 如何在中运行 Selenium WebDriver 测试用例Chrome?但它似乎不在Python中(没有标记任何编程语言,它是什么?)
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 代码,我应该将文件放在 Windows 10 的哪个位置电脑?
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.
当浏览器窗口打开(以及命令提示符窗口)时,Chrome 挂起时遇到了同样的问题.
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/下载
chromedriver_win32.zip 文件中的版本在我的 64 位系统上运行.
The version in the chromedriver_win32.zip file is working on my 64-bit system.
这篇关于如何在 Windows 10 上安装 ChromeDriver 并使用 Chrome 运行 Selenium 测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!