问题
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:
While working with
Selenium 3.4.0downloading 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 theIEDriverServer.exewithin our code block to reduce manual configuration and be able to work with multiple versions ofIEDriverServer.exeas per your requirement as follows:driver=webdriver.Ie(r'C:\Utility\BrowserDrivers\IEDriverServer.exe')The error you are seeing exactly points me to the mismatch within
IEDriverServer.exeversion, installedIE Browserversion and your underlyingOSversion. Here either you have configured64 bit IEDriverServer.exeto work with32 bit IE browseror you have configured32 bit IEDriverServer.exeto work with64 bit IE browser. You can find some discussions on the errorHRESULT 800700C1 ('%1 is not a valid Win32 application.')here and here.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