通过Selenium启动Chrome [英] Getting Chrome to launch via Selenium

查看:248
本文介绍了通过Selenium启动Chrome的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我对此很陌生,在从python中的硒中获取Chrome浏览器实例时遇到了问题.我正在使用Windows8.我已经下载了chromedriver二进制文件并将其添加到我的路径中,但是在Python中出现以下错误:

Hi all I'm very new to this and am having issues getting an instance of a Chrome browser from selenium in python. I'm using Windows 8. I have downloaded the chromedriver binary and added it to my path but I get the following error in Python:

selenium.common.exceptions.WebDriverException: Message: 'ChromeDriver executable needs to be available in the path.   

以下行会发生此错误:

driver = webdriver.Chrome(executable_path='path\to\chromedriver_win32_2.0')  

任何帮助将不胜感激.谢谢你.

Any help is greatly appreciated. Thank you.

推荐答案

有两种设置方法,您莫名其妙地将其混淆了.

Two ways to set it, you somehow mixed up.

  • chromedriver.exe的路径放入PATH(在Windows上),因此您的PATH设置正确,但是需要调用默认构造函数.

  • Put the chromedriver.exe's path into PATH (on Windows), so your PATH setting is correct, but you need to call the default constructor.

driver = webdriver.Chrome()

webdriver.Chrome(executable_path='some path')中指定路径.在这里,您需要可执行文件的完整路径,而不是目录.

Specify the path in webdriver.Chrome(executable_path='some path'). Here you need the full path to the executable, not the directory.

webdriver.Chrome(executable_path=r'C:\Users\HaranKumar\Downloads\chromedriver_win32_2.0\chromedriver.exe')

选择任意一个.

这篇关于通过Selenium启动Chrome的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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