python - 带有 python 绑定(bind)的 Selenium 可以启动 Firefox,但不能启动 Explorer 和 Chrome 浏览器

标签 python selenium python-3.x selenium-webdriver

我想使用 selenium 在 Windows XP SP3 上启动 Internet Explorer (8) 浏览器。我编写了这些行:

from selenium import webdriver
class InternetExplorer8:
    def ie8(self):
        self.browser=webdriver.Ie()
        self.browser.get("http://www.begueradj.com")
if __name__=='__main__':
    IE=InternetExplorer8()
    IE.ie8()

我收到此错误:

self.iedriver.start() File "C:\Python34\lib\site-packages\selenium\webdriver\ie\service.py", line 73, in start and read up at http://code.google.com/p/selenium/wiki/InternetExplorerDriver") selenium.common.exceptions.WebDriverException: Message: 'IEDriver executable needs to be available in the path. Please download from http://selenium-release.storage.googleapis.com/index.html and read up at http://code.google.com/p/selenium/wiki/InternetExplorerDriver

请注意,我使用相同的代码启动 Firefox 没有任何问题,除了 Internet Explorer 和 crhome(输出类似的错误)。我该如何解决这个问题?

最佳答案

您需要download Internet Explorer driver并将其路径放入 PATH 环境变量中。

或者,向 webdriver.Ie() 提供 executable_path 参数:

self.browser = webdriver.Ie(executable_path='path\to\iedriver\driver.exe')

关于python - 带有 python 绑定(bind)的 Selenium 可以启动 Firefox,但不能启动 Explorer 和 Chrome 浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24865067/

相关文章:

python - 如何存储 python nosetests 的测试数据?

python - 查找长度为 3 的总组合,使得总和可被给定数字整除且 i<j<k

python - 如何等待 iframe 使用 phantomjs 在 selenium python 中加载

python - 无法获取所有子项(动态加载)selenium python

python - 使用 Selenium 抓取 id_str 对象

python - 遍历 xarray 数据集中的 dataArray 属性

python - Django 模板中的命名冲突

python - 我可以使用 "unaliased"属性名称初始化 pydantic 模型吗?

python - Python 3 中的 Google OAuth 错误

python - 在 matplotlib 中 show() 之后保留无花果的内容?