简体   繁体   English

无法通过Selenium WebDriver python绑定启动Internet Explorer

[英]Unable to launch Internet Explorer through Selenium WebDriver python bindings

I've downloaded IEDriver and tested both 32 and 64bit versions (I am running 64bit Windows 7) and I included the folder containing the EXE to path in environment variables. 我已经下载了IEDriver并测试了32位和64位版本(我正在运行64位Windows 7),并且在环境变量中包括了包含EXE路径的文件夹。

I've restarted Eclipse and my whole system but still get the exception 我已经重新启动了Eclipse和整个系统,但是仍然出现异常

selenium.common.exceptions.WebDriverException: Message:
'IEDriver executable needs to be available in the path.
Please download from http://code.google.com/p/selenium/downloads/list
and read up at http://code.google.com/p/selenium/wiki/InternetExplorerDriver' 

Below is my test setup to launch IE: 以下是我启动IE的测试设置:

def setUp(self):
    self.driver = webdriver.Ie()
    self.driver.implicitly_wait(30)
    self.base_url = "https://accounts.google.com/"
    self.verificationErrors = []
    self.accept_next_alert = True

I'm stumped. 我很沮丧 I've had it working previously but removed it and now want to put it back on my system. 我以前曾使用过它,但现在将其删除了,现在想将其放回系统中。 I'm using Python 3.3, Eclipse 4.2.2, Selenium 2.31 and IE 10.0.92 我正在使用Python 3.3,Eclipse 4.2.2,Selenium 2.31和IE 10.0.92

Any ideas? 有任何想法吗?

How did you set your path? 您是如何设定道路的?

For example, if your IEDriverServer.exe is in C:\\ , then you should add C:\\ to your PATH, instead of C:\\IEDriverServer.exe 例如,如果IEDriverServer.exeC:\\ ,则应将C:\\添加到PATH中,而不是C:\\IEDriverServer.exe

EDIT : In your case, there is a semi colon before C:\\IEDriver , which should be removed. 编辑 :在您的情况下,在C:\\IEDriver之前有一个分号,应将其删除。

Then restart your Eclipse and try again. 然后重新启动Eclipse,然后重试。

EDIT : Could you please also try specify path to IEDriverServer.exe in the code? 编辑 :您能否也请尝试在代码中指定IEDriverServer.exe的路径?

from selenium import webdriver

driver = webdriver.Ie(r"C:\\IEDriver\\IEDriverServer.exe")

It seems that newer Selenium 2 versions use different approach to communicate with IE than earlier. 似乎较新的Selenium 2版本使用与早期版本不同的方法与IE通信。 Just follow the instructions in the below link and you should be fine. 只需按照以下链接中的说明进行操作,就可以了。

Driver executable must be set by the webdriver.ie.driver system property 驱动程序可执行文件必须由webdriver.ie.driver系统属性设置

Also Check the below point. 还要检查以下几点。 I have encountered the same when I am Automating IE web application 自动化IE Web应用程序时遇到相同的问题

On IE 7 or higher on Windows Vista or Windows 7, you must set the Protected Mode settings for each zone to be the same value. 在Windows Vista或Windows 7的IE 7或更高版本上,必须将每个区域的保护模式设置设置为相同的值。 The value can be on or off, as long as it is the same for every zone. 该值可以打开或关闭,只要每个区域都相同即可。 To set the Protected Mode settings, choose "Internet Options..." from the Tools menu, and click on the Security tab. 要设置保护模式设置,请从“工具”菜单中选择“ Internet选项...”,然后单击“安全性”选项卡。 For each zone, there will be a check box at the bottom of the tab labeled "Enable Protected Mode". 对于每个区域,选项卡底部都会有一个标记为“启用保护模式”的复选框。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM