我正在使用Selenium来自动化IE11的网页测试,我按照https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver#required-configuration的指示执行了所有步骤,但是当我运行自动化时仍然出错,我无法启动IE浏览器。
但是我仍然无法启动IE浏览器,我收到了以下错误:
======================================================================
ERROR: test_contact (__main__.IETestCases)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_ie.py", line 528, in setUp
IEDefault.setUp(self)
File "test_ie.py", line 88, in setUp
self.driver = webdriver.Ie(r'C:\Users\jzhao\WebPageTest\IEDriverServer_x64_3.4.0\IEDriverServer.exe')
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 98, in __init__
self.start_session(desired_capabilities, browser_profile)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 188, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 256, in execute
self.error_handler.check_response(response)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 165, in check_response
raise exception_class(value)
WebDriverException: Message: Error 400: Bad Request
Invalid URI: [http://127.0.0.1:56761/session]
----------------------------------------------------------------------
版本:
答案 0 :(得分:0)
以下是您的问题的答案:
在使用Selenium 3.4.0
,IEDriverServer 3.4.0
,IE 11
到Python 3.6.1
绑定时,您可以获取DesiredCapabilities
类的帮助以进行一些配置以打开IE 11
如下:
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
cap = DesiredCapabilities().INTERNETEXPLORER
cap['platform'] = "Win8"
cap['version'] = "11"
cap['browserName'] = "internet explorer"
cap['ignoreProtectedModeSettings'] = True
cap['nativeEvents'] = False
cap['requireWindowFocus'] = True
cap['INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS'] = True
driver=webdriver.Ie(capabilities=cap, executable_path=r'C:\Utility\BrowserDrivers\IEDriverServer.exe')
driver.get("https://www.facebook.com/")
如果这回答你的问题,请告诉我。