Selenium是一个十分好用的web自动测试工具,它录制的案例除了可以保存成自用的格式以外,还支持生成Java、C#、Python、Ruby代码。

Selenium提供了丰富的API,可以很好的支持二次开发。使用WebDriver来打开FireFox和Chrome的时候没有遇到问题,但是在我打开IE的时候,问题就出来了(我使用的是Python)

WebDriverException: Message: u'Unexpected error launching Internet Explorer. Protected Mode must be set to the same value (enabled or disabled) for all zones.'

后来查了好些资料,找到了两种解决办法:

1)修改IE的安全策略,就像Exception里面提示的那样。

2)在生成webdriver对象之前先执行这些代码:

1 from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
2 DesiredCapabilities.INTERNETEXPLORER['ignoreProtectedModeSettings'] = True

好了,再运行一下,看看是不是可以打开IE了。



相关文章:

  • 2022-12-23
  • 2021-06-13
  • 2022-12-23
  • 2021-11-29
  • 2022-01-07
  • 2021-11-18
  • 2021-05-20
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-11
  • 2021-04-06
  • 2021-05-03
  • 2021-04-21
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案