selenium使用IE 浏览器问题

时间:2021-06-29 07:53:29
代码如下:
#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:\Users\xxxxx\workspace\aautotest\test_ie.py", line 12, in <module>
driver=webdriver.Ie()
File "D:\Python27\lib\site-packages\selenium\webdriver\ie\webdriver.py", line 54, in __init__
desired_capabilities=capabilities)
File "D:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 74, in __init__
self.start_session(desired_capabilities, browser_profile)
File "D:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 123, in start_se
ssion
'desiredCapabilities': desired_capabilities,
File "D:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 175, in execute
self.error_handler.check_response(response)
File "D:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.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的保护模式都选上或都勾掉就可以了:

selenium使用IE 浏览器问题