当前位置: 首页 > 知识库问答 >
问题:

Selenium IE驱动程序未在用户配置文件中启动浏览器

邬浩涆
2023-03-14
from  selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

cap = DesiredCapabilities().INTERNETEXPLORER
cap['ignoreProtectedModeSettings'] = True
cap['IntroduceInstabilityByIgnoringProtectedModeSettings'] = True
cap['nativeEvents'] = True
cap['ignoreZoomSetting'] = True
cap['requireWindowFocus'] = True
browser = webdriver.Ie(capabilities=cap, executable_path='C:\\IEDriver\\IEDriverServer.exe')
browser.get('https://www.bharti-axagi.co.in/')

回溯(最近一次调用):文件“C:/users/hitesh kumar/pycharmprojects/open ie/open ie1.py”,第11行,在browser=webdriver.ie(capabilities=cap,executable_path='c:\iedriver\iedriverserver.exe')文件“C:\python27\lib\site-packages\selenium\webdriver\ie\webdriver.py”,第88行,在init desired_capabilities=capabilites)文件“C:\python27\lib\site-packages\selenium\webdriver\remote\webdriver.py”,第156行,在init self.start_session:\python27\lib\site-packages\selenium\webdriver\remote\webdriver.py“,第251行,在start_session response=self.execute(command.new_session,parameters)文件”C:\python27\lib\site-packages\selenium\webdriver\remote\webdriver.py“中,第320行,在execute self.error_handler.check_response(响应)文件”C:\python27\lib\site-packages\selenium\webdriver\remote\webdriver.py“中,第208行,在check_response提高exception_class(值)

共有1个答案

洪祺
2023-03-14

只需更改cap=DesiredCapabilities.InternetExplorer

致:

cap = DesiredCapabilities.INTERNETEXPLORER.copy()

在文档中是这样做的...

 类似资料: