mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-04 21:18:01 +08:00
微调
This commit is contained in:
parent
46afbc767f
commit
4c2364b08a
@ -392,7 +392,7 @@ def _create_chrome(chrome_path: str, port: str, args: list, proxy: dict) -> tupl
|
||||
else:
|
||||
args1.append(arg)
|
||||
|
||||
args = ' '.join(args1)
|
||||
args = ' '.join(set(args1))
|
||||
|
||||
if proxy:
|
||||
args = f'{args} --proxy-server={proxy["http"]}'
|
||||
|
@ -777,7 +777,12 @@ class ElementsByXpath(object):
|
||||
|
||||
|
||||
class Select(object):
|
||||
"""Select 类专门用于处理 d 模式下 select 标签"""
|
||||
|
||||
def __init__(self, ele: DriverElement):
|
||||
"""初始化 \n
|
||||
:param ele: select 元素对象
|
||||
"""
|
||||
if ele.tag != 'select':
|
||||
raise TypeError(f"Select only works on <select> elements, not on {ele.tag}")
|
||||
|
||||
@ -807,21 +812,21 @@ class Select(object):
|
||||
"""返回所有选项元素组成的列表"""
|
||||
return self.inner_ele.eles('tag:option')
|
||||
|
||||
@property
|
||||
def selected_options(self) -> List[DriverElement]:
|
||||
"""返回所有被选中的option元素列表 \n
|
||||
:return: DriverElement对象组成的列表
|
||||
"""
|
||||
return [x for x in self.options if x.is_selected()]
|
||||
|
||||
@property
|
||||
def selected_option(self) -> Union[DriverElement, None]:
|
||||
"""返回第一个被选中的option元素 \n
|
||||
"""返回第一个被选中的option元素 \n
|
||||
:return: DriverElement对象或None
|
||||
"""
|
||||
ele = self.inner_ele.run_script('return arguments[0].options[arguments[0].selectedIndex];')
|
||||
return None if ele is None else DriverElement(ele, self.inner_ele.page)
|
||||
|
||||
@property
|
||||
def selected_options(self) -> List[DriverElement]:
|
||||
"""返回所有被选中的option元素列表 \n
|
||||
:return: DriverElement对象组成的列表
|
||||
"""
|
||||
return [x for x in self.options if x.is_selected()]
|
||||
|
||||
def clear(self) -> None:
|
||||
"""清除所有已选项"""
|
||||
self.select_ele.deselect_all()
|
||||
@ -874,7 +879,7 @@ class Select(object):
|
||||
para_type: str = 'text',
|
||||
deselect: bool = False) -> Union[bool, list]:
|
||||
"""选定或取消选定下拉列表中多个子元素 \n
|
||||
:param text_value_index: 根据文本、值选或序号择选项,若允许多选,传入list或tuple可多选
|
||||
:param text_value_index: 根据文本、值选或序号择选多项
|
||||
:param para_type: 参数类型,可选 'text'、'value'、'index'
|
||||
:param deselect: 是否取消选择
|
||||
:return: 是否选择成功
|
||||
@ -910,7 +915,7 @@ class Select(object):
|
||||
text_value_index: Union[list, tuple] = None,
|
||||
para_type: str = 'text') -> Union[bool, list]:
|
||||
"""取消选定下拉列表中多个子元素 \n
|
||||
:param text_value_index: 根据文本、值选或序号择选项,若允许多选,传入list或tuple可多选
|
||||
:param text_value_index: 根据文本、值选或序号取消择选多项
|
||||
:param para_type: 参数类型,可选 'text'、'value'、'index'
|
||||
:return: 是否选择成功
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user