ChromeDriver 的默认位置是什么以及在 Windows 上安装 Chrome [英] What is default location of ChromeDriver and for installing Chrome on Windows
问题描述
我需要在 Windows 操作系统上安装 chromedriver
.在下面的文章中,他们指定:
I need to install chromedriver
on Windows OS. In the article below they specify:
https://sites.google.com/a/chromium.org/chromedriver/getting-started
"...ChromeDriver 希望您默认安装 Chrome您平台的位置..."
"...ChromeDriver expects you to have Chrome installed in the default location for your platform..."
但我不确定默认位置是什么?
But I'm not sure what is the default location ?
在 Mac 操作系统上是 /usr/local/bin
.
On Mac OS it's /usr/local/bin
.
有了这个,我也不必明确指定路径或设置系统路径.
With this I don't have to specify path explicitly or setup system path either.
如何在 Windows 操作系统上实现相同的功能?
How to achieve the same on Windows OS?
推荐答案
对于 Selenium 打开浏览器必须使用的任何驱动程序(chromedriver
、geckodriver
等),您不必担心它的安装位置,只要它设置在 PATH
变量中即可.
For any driver that Selenium must use to open the browser (chromedriver
, geckodriver
, etc), you don't have to worry about where it is installed, as long as it's set in the PATH
variable.
如果你在操作系统 PATH
变量中设置了它,你必须能够从 command
或 cmd
运行它(它总是确保它正常工作).
If you have it set in the OS PATH
variable, you must be able to run it from the command
or cmd
(it's always good to make sure it's working).
以下是设置方法(附加到现有值):
Here's how you can set it (append to the existing value):
- 文章:https://www.computerhope.com/issues/ch000549.htm一个>
- 视频:https://www.youtube.com/watch?v=dz59GsdvUF8一个>
然后你可以按如下方式实例化它:
Then you can just instantiate it as follows:
WebDriver driver = new FirefoxDriver();
或
WebDriver driver = new ChromeDriver();
希望对你有所帮助.
这篇关于ChromeDriver 的默认位置是什么以及在 Windows 上安装 Chrome的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!