MixPage的__init__()的drission参数可接收's'或'd',以简易方式创建对象

This commit is contained in:
g1879 2020-06-07 00:14:42 +08:00
parent f3f4be5793
commit 50f2130f9c

View File

@ -32,12 +32,15 @@ class MixPage(Null, SessionPage, DriverPage):
这些功能由DriverPage和SessionPage类实现
"""
def __init__(self, drission: Drission = None, mode: str = 'd', timeout: float = 10):
def __init__(self, drission: Union[Drission, str] = None, mode: str = 'd', timeout: float = 10):
"""初始化函数
:param drission: 整合了driver和session的类
:param drission: 整合了driver和session的类传入's''d'时快速配置相应模式
:param mode: 默认使用selenium的d模式
"""
super().__init__()
if drission in ['s', 'd']:
mode = drission
drission = None
self._drission = drission or Drission()
self._session = None
self._driver = None