15889369825 发表于 2016-12-12 14:31:01

python+ie

python调用ie浏览器   报self.driver = webdriver.Ie()

File "C:\Python27\lib\site-packages\selenium\webdriver\ie\webdriver.py", line 57, in __init__
    desired_capabilities=capabilities)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 92, in __init__
    self.start_session(desired_capabilities, browser_profile)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 179, in start_session
    response = self.execute(Command.NEW_SESSION, capabilities)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 236, in execute
    self.error_handler.check_response(response)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 192, in check_response
    raise exception_class(message, screen, stacktrace)
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 same value (enabled or disabled) for all zones.
大家是怎么调用ie的

若尘_51 发表于 2016-12-12 14:41:30

这是由于IE安全策略引起的,解决方法

1.在调用浏览器的前面增加代码
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
DesiredCapabilities.INTERNETEXPLORER['ignoreProtectedModeSettings'] = True

2.internet/本地intarnet/受信任的站点/受限制站点中的启用保护模式全部勾选或者全部不选

15889369825 发表于 2016-12-12 14:57:48

若尘_51 发表于 2016-12-12 14:41
这是由于IE安全策略引起的,解决方法

1.在调用浏览器的前面增加代码


加上了代码   打开的ie页面显示This is the initial start page for the WebDriver server.

若尘_51 发表于 2016-12-12 15:08:10

15889369825 发表于 2016-12-12 14:57
加上了代码   打开的ie页面显示This is the initial start page for the WebDriver server.

把你的脚本和错误附上来看看

15889369825 发表于 2016-12-12 15:10:33

若尘_51 发表于 2016-12-12 15:08
把你的脚本和错误附上来看看

# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import unittest, time, re

class test (unittest.TestCase):
    def setUp(self):
      from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
      DesiredCapabilities.INTERNETEXPLORER['ignoreProtectedModeSettings'] = True
      self.driver = webdriver.Ie()
      self.driver.implicitly_wait(30)
      self.base_url = "http://test.robotscloud.com/"
      self.verificationErrors = []
      self.accept_next_alert = True

若尘_51 发表于 2016-12-12 15:30:04

15889369825 发表于 2016-12-12 15:10
# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.by import...

修改注册表: HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Zoom
修改ZoomFactor的值110000,改成100000,保存退出就可以了。

15889369825 发表于 2016-12-12 15:57:44

若尘_51 发表于 2016-12-12 15:30
修改注册表: HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Zoom
修改ZoomFactor的值110000 ...

厉害了我的哥,网上都没这么详细

梦想家 发表于 2016-12-12 16:39:19

我去好厉害呀

Miss_love 发表于 2016-12-14 09:31:02

应该是经验总结
页: [1]
查看完整版本: python+ie