mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
get_tab()参数修改,可接收序号;修复8x版浏览器select报错
This commit is contained in:
parent
893a8e4957
commit
ddd7aba9ae
@ -138,12 +138,21 @@ class ChromiumPage(ChromiumBase):
|
||||
"""返回浏览器进程id"""
|
||||
return self.browser.process_id
|
||||
|
||||
def get_tab(self, tab_id=None):
|
||||
def get_tab(self, id_or_num=None):
|
||||
"""获取一个标签页对象
|
||||
:param tab_id: 要获取的标签页id,为None时获取当前tab
|
||||
:param id_or_num: 要获取的标签页id或序号,为None时获取当前tab,序号不是视觉排列顺序,而是激活顺序
|
||||
:return: 标签页对象
|
||||
"""
|
||||
return tab_id if isinstance(tab_id, ChromiumTab) else ChromiumTab(self, tab_id or self.tab_id)
|
||||
if isinstance(id_or_num, str):
|
||||
return ChromiumTab(self, id_or_num)
|
||||
elif isinstance(id_or_num, int):
|
||||
return ChromiumTab(self, self.tabs[id_or_num])
|
||||
elif id_or_num is None:
|
||||
return ChromiumTab(self, self.tab_id)
|
||||
elif isinstance(id_or_num, ChromiumTab):
|
||||
return id_or_num
|
||||
else:
|
||||
raise TypeError(f'id_or_num需传入tab id或序号,非{id_or_num}。')
|
||||
|
||||
def find_tabs(self, title=None, url=None, tab_type=None, single=True):
|
||||
"""查找符合条件的tab,返回它们的id组成的列表
|
||||
|
@ -54,7 +54,7 @@ class ChromiumPage(ChromiumBase):
|
||||
@property
|
||||
def set(self) -> ChromiumPageSetter: ...
|
||||
|
||||
def get_tab(self, tab_id: Union[str, ChromiumTab] = None) -> ChromiumTab: ...
|
||||
def get_tab(self, tab_id: Union[str, ChromiumTab, int] = None) -> ChromiumTab: ...
|
||||
|
||||
def find_tabs(self, title: str = None, url: str = None,
|
||||
tab_type: Union[str, list, tuple] = None, single: bool = True) -> Union[str, List[str]]: ...
|
||||
|
@ -297,12 +297,21 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
||||
elif self._mode == 'd':
|
||||
return super(SessionPage, self).get_cookies(as_dict, all_domains, all_info)
|
||||
|
||||
def get_tab(self, tab_id=None):
|
||||
def get_tab(self, id_or_num=None):
|
||||
"""获取一个标签页对象
|
||||
:param tab_id: 要获取的标签页id,为None时获取当前tab
|
||||
:param id_or_num: 要获取的标签页id或序号,为None时获取当前tab,序号不是视觉排列顺序,而是激活顺序
|
||||
:return: 标签页对象
|
||||
"""
|
||||
return tab_id if isinstance(tab_id, WebPageTab) else WebPageTab(self, tab_id or self.tab_id)
|
||||
if isinstance(id_or_num, str):
|
||||
return WebPageTab(self, id_or_num)
|
||||
elif isinstance(id_or_num, int):
|
||||
return WebPageTab(self, self.tabs[id_or_num])
|
||||
elif id_or_num is None:
|
||||
return WebPageTab(self, self.tab_id)
|
||||
elif isinstance(id_or_num, WebPageTab):
|
||||
return id_or_num
|
||||
else:
|
||||
raise TypeError(f'id_or_num需传入tab id或序号,非{id_or_num}。')
|
||||
|
||||
def new_tab(self, url=None, new_window=False, background=False, new_context=False):
|
||||
"""新建一个标签页
|
||||
|
@ -122,7 +122,7 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
||||
def get_cookies(self, as_dict: bool = False, all_domains: bool = False,
|
||||
all_info: bool = False) -> Union[dict, list]: ...
|
||||
|
||||
def get_tab(self, tab_id: Union[str, WebPageTab] = None) -> WebPageTab: ...
|
||||
def get_tab(self, id_or_num: Union[str, WebPageTab, int] = None) -> WebPageTab: ...
|
||||
|
||||
def new_tab(self, url: str = None, new_window: bool = False, background: bool = False,
|
||||
new_context: bool = False) -> WebPageTab: ...
|
||||
|
@ -36,7 +36,7 @@ class SelectElement(object):
|
||||
@property
|
||||
def options(self):
|
||||
"""返回所有选项元素组成的列表"""
|
||||
return self._ele.eles('xpath://option')
|
||||
return [i for i in self._ele.eles('xpath://option') if not isinstance(i, int)]
|
||||
|
||||
@property
|
||||
def selected_option(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user