代码如下:
#coding=utf-8 from selenium import webdriver driver=webdriver.Ie() driver.get('https://www.baidu.com') print driver.title driver.quit()
报错:
Traceback (most recent call last): File "D:Usersxxxxxworkspaceaautotest est_ie.py", line 12, in <module> driver=webdriver.Ie() File "D:Python27libsite-packagesseleniumwebdriveriewebdriver.py", line 54, in __init__ desired_capabilities=capabilities) File "D:Python27libsite-packagesseleniumwebdriver emotewebdriver.py", line 74, in __init__ self.start_session(desired_capabilities, browser_profile) File "D:Python27libsite-packagesseleniumwebdriver emotewebdriver.py", line 123, in start_se ssion 'desiredCapabilities': desired_capabilities, File "D:Python27libsite-packagesseleniumwebdriver emotewebdriver.py", line 175, in execute self.error_handler.check_response(response) File "D:Python27libsite-packagesseleniumwebdriver emoteerrorhandler.py", line 166, in check _response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: Unexpected error launching Internet Explorer . Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the s ame value (enabled or disabled) for all zones.
解决办法:把ie的保护模式都选上或都勾掉就可以了: