用IE浏览器报错
来源:3-4 继承基类实现浏览器个性化

慕粉1926212165
2022-05-10
class IE(BROWSER):
CLEAN_SESSION = True
def __init__(self):
super(IE, self).__init__(
browser_type=Ie,
option_type=IeOptions,
driver_path=super().IE_DRIVER_PATH
)
@property
def options(self):
ie_options = self._option
ie_options.ensure_clean_session = self.CLEAN_SESSION
return ie_options
@property
def browser(self):
ie = self._browser(self._path, options=self.options)
ie.implicitly_wait(self.IMP_TIME)
ie.set_script_timeout(self.SCRIPT_TIME_OUT)
ie.set_page_load_timeout(self.PAGE_LOAD_TIME)
ie.maximize_window()
return ie
with IE().browser as _ie:
_ie.get(‘http://127.0.0.1/zentao/user-login-L3plbnRhby8=.html’)
from time import sleep
sleep(3)
运行后报如下错误:
D:\Users\wangyunju\AppData\Local\Programs\Python\Python310\python.exe E:/PyCharmProject/autotest_framework/chapter3/bo_demo.py
Traceback (most recent call last):
File “E:\PyCharmProject\autotest_framework\chapter3\bo_demo.py”, line 132, in
with IE().browser as _ie:
File “E:\PyCharmProject\autotest_framework\chapter3\bo_demo.py”, line 120, in browser
ie = self._browser(self._path, options=self.options)
File “D:\Users\wangyunju\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\ie\webdriver.py”, line 79, in init
capabilities = options.to_capabilities()
TypeError: Options.to_capabilities() missing 1 required positional argument: ‘self’
Process finished with exit code 1
2回答
-
慕粉1926212165
提问者
2022-05-11
ie_options = self._option 应该为 ie_options = self._option()
112022-05-17 -
托尼老师
2022-05-17
同学,请看楼下的回答。
00
相似问题