Setting up selenium to work with internet explorer

ε祈祈猫儿з 提交于 2020-01-23 16:17:00

问题


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")

And the error code I am receiving is:

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/'

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


回答1:


You have to consider a couple of facts here:

  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')
    
  2. 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.

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



来源:https://stackoverflow.com/questions/45571476/setting-up-selenium-to-work-with-internet-explorer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!