[英]Python / Selenium - “chromedriver” executable needs to be in a PATH
I was trying to do something with a gecko driver ( Selenium in this case ) and I can't get my chrome driver to work.我试图用壁虎驱动程序(在这种情况下为 Selenium)做一些事情,但我无法让我的 chrome 驱动程序工作。 Knowing that I am on Mac Sierra, and that my script is in the same folder as my chrome driver, here is my code
知道我在 Mac Sierra 上,并且我的脚本与我的 chrome 驱动程序在同一个文件夹中,这是我的代码
from selenium import webdriver
import time
url = "https://accounts.google.com/signup/v2/webcreateaccount?flowName=GlifWebSignIn&flowEntry=SignUp"
driver = webdriver.Chrome("chromedriver")
driver.get(url)
Thanks for the help谢谢您的帮助
Try this:尝试这个:
from selenium import webdriver
driver= webdriver.Chrome(executable_path="C:/users/usr/Desktop/chromedriver.exe")
url = 'your website'
driver.get(url)
make sure you are using this slash (/) in your file path to the chrome driver (as shown above)确保您在 chrome 驱动程序的文件路径中使用此斜杠 (/)(如上所示)
You can test if it actually is in the PATH, Open your command prompt go to the location of your chromedriver and hit enter.您可以测试它是否真的在 PATH 中,打开命令提示符 go 到您的 chromedriver 的位置,然后按 Enter。 you will get below message:
您将收到以下消息:
C:\>
chromedriver.exe
Starting ChromeDriver 76.0.3809.68 (420c9498db8ce8fcd190a954d51297672c1515d5-ref
s/branch-heads/3809@{#864}) on port 9515
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent
access by malicious code.
Then you need to setup PATH like below before you start your test:然后你需要在开始测试之前像下面这样设置 PATH:
driver = webdriver.Chrome('/path/to/chromedriver')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.