设置硒以与Internet Explorer一起使用 [英] Setting up selenium to work with internet explorer

查看:89
本文介绍了设置硒以与Internet Explorer一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个python脚本,可以执行该脚本,并且完全可以在Google Chromedriver下执行我想要的操作.但是,为了确保我的可执行文件可以在所有PC上正常工作,我希望脚本可以与Internet Explorer驱动程序一起工作,但是遇到了问题.我已经附上了我要在下面运行的示例测试代码以及​​收到的错误消息.

I have created a python script that I can execute and does exactly what I want under the Google Chromedriver. However, to make sure that my executable can work on all PCs, I would like to have my script work with the internet explorer driver but I am having issues. I have attached a sample test code I am trying to run below along with the error message I am receiving.

from selenium import webdriver
driver = webdriver.Ie()
driver.get("google.com")

我收到的错误代码是:

selenium.common.exceptions.WebDriverException: Message: Unexpected error 
launching Internet Explorer. IELaunchURL() returned HRESULT 800700C1 ('%1 is 
not a valid Win32 application.') for URL 'http://localhost:58689/'

有什么想法吗?我已经安装了IEdriver,并将其与上面提到的test.py文件一起放在桌面上.

Any ideas? I have installed the IEdriver and placed it on my desktop along with the test.py file I mentioned above.

推荐答案

您必须在这里考虑几个事实:

You have to consider a couple of facts here:

  1. 在使用Selenium 3.4.0进行下载IEdriver并将其与test.py文件一起放置在桌面上时,可能还不够.理想情况下,我们应该在代码块内传递IEDriverServer.exe的绝对路径,以减少手动配置,并能够按照您的要求使用IEDriverServer.exe的多个版本,如下所示:

  1. While working with Selenium 3.4.0 downloading the IEdriver and placing it on your desktop along with the test.py file may not suffice. Ideally we should be passing the absolute path of the IEDriverServer.exe within our code block to reduce manual configuration and be able to work with multiple versions of IEDriverServer.exe as per your requirement as follows:

driver=webdriver.Ie(r'C:\Utility\BrowserDrivers\IEDriverServer.exe')

  • 您看到的错误将我确切地指出了IEDriverServer.exe版本,已安装的IE Browser版本和您的基础OS版本之间的不匹配.在这里,您已经配置了64 bit IEDriverServer.exe32 bit IE browser一起使用,或者您已经配置了32 bit IEDriverServer.exe64 bit IE browser一起使用.您可以找到有关错误 HRESULT 800700C1 ('%1 is not a valid Win32 application.') 此处 .

  • The error you are seeing exactly points me to the mismatch within IEDriverServer.exe version, installed IE Browser version and your underlying OS version. Here either you have configured 64 bit IEDriverServer.exe to work with 32 bit IE browser or you have configured 32 bit IEDriverServer.exe to work with 64 bit IE browser. You can find some discussions on the error HRESULT 800700C1 ('%1 is not a valid Win32 application.') here and here.

    如果您使用的是IE 11,则可以考虑按照提到的规范设置测试环境

    If you are using IE 11 you may consider to set up your Test Environment as per the specification mentioned here.

    这篇关于设置硒以与Internet Explorer一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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