如何在Windows 10上安装ChromeDriver并在Chrome上运行Selenium测试? [英] How do I install ChromeDriver on Windows 10 and run Selenium tests with Chrome?

查看:366
本文介绍了如何在Windows 10上安装ChromeDriver并在Chrome上运行Selenium测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一台Ubuntu服务器,可用于在Chrome和Firefox(我安装了ChromeDriver)上运行Selenium测试,并且我还想在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)
        ...

我还找到了如何在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 ,但是如果我想为Windows 10和Windows 10保留相同的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测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆