mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
new_tab()改为返回标签页对象
This commit is contained in:
parent
30f022fe71
commit
ba1c3fb3cc
@ -172,8 +172,7 @@ class ChromiumPage(ChromiumBase):
|
|||||||
:param tab_id: 要获取的标签页id,为None时获取当前tab
|
:param tab_id: 要获取的标签页id,为None时获取当前tab
|
||||||
:return: 标签页对象
|
:return: 标签页对象
|
||||||
"""
|
"""
|
||||||
tab_id = tab_id or self.tab_id
|
return tab_id if isinstance(tab_id, ChromiumTab) else ChromiumTab(self, tab_id or self.tab_id)
|
||||||
return ChromiumTab(self, tab_id)
|
|
||||||
|
|
||||||
def find_tabs(self, title=None, url=None, tab_type=None, single=True):
|
def find_tabs(self, title=None, url=None, tab_type=None, single=True):
|
||||||
"""查找符合条件的tab,返回它们的id组成的列表
|
"""查找符合条件的tab,返回它们的id组成的列表
|
||||||
@ -197,7 +196,7 @@ class ChromiumPage(ChromiumBase):
|
|||||||
and (tab_type is None or i['type'] in tab_type))]
|
and (tab_type is None or i['type'] in tab_type))]
|
||||||
return r[0]['id'] if r and single else r
|
return r[0]['id'] if r and single else r
|
||||||
|
|
||||||
def new_tab(self, url=None, switch_to=False):
|
def _new_tab(self, url=None, switch_to=False):
|
||||||
"""新建一个标签页,该标签页在最后面
|
"""新建一个标签页,该标签页在最后面
|
||||||
:param url: 新标签页跳转到的网址
|
:param url: 新标签页跳转到的网址
|
||||||
:param switch_to: 新建标签页后是否把焦点移过去
|
:param switch_to: 新建标签页后是否把焦点移过去
|
||||||
@ -226,6 +225,14 @@ class ChromiumPage(ChromiumBase):
|
|||||||
|
|
||||||
return tid
|
return tid
|
||||||
|
|
||||||
|
def new_tab(self, url=None, switch_to=False):
|
||||||
|
"""新建一个标签页,该标签页在最后面
|
||||||
|
:param url: 新标签页跳转到的网址
|
||||||
|
:param switch_to: 新建标签页后是否把焦点移过去
|
||||||
|
:return: 新标签页对象
|
||||||
|
"""
|
||||||
|
return ChromiumTab(self, self._new_tab(url, switch_to))
|
||||||
|
|
||||||
def to_main_tab(self):
|
def to_main_tab(self):
|
||||||
"""跳转到主标签页"""
|
"""跳转到主标签页"""
|
||||||
self.to_tab(self._main_tab)
|
self.to_tab(self._main_tab)
|
||||||
|
@ -63,12 +63,14 @@ class ChromiumPage(ChromiumBase):
|
|||||||
@property
|
@property
|
||||||
def set(self) -> ChromiumPageSetter: ...
|
def set(self) -> ChromiumPageSetter: ...
|
||||||
|
|
||||||
def get_tab(self, tab_id: str = None) -> ChromiumTab: ...
|
def get_tab(self, tab_id: Union[str, ChromiumTab] = None) -> ChromiumTab: ...
|
||||||
|
|
||||||
def find_tabs(self, title: str = None, url: str = None,
|
def find_tabs(self, title: str = None, url: str = None,
|
||||||
tab_type: Union[str, list, tuple, set] = None, single: bool = True) -> Union[str, List[str]]: ...
|
tab_type: Union[str, list, tuple, set] = None, single: bool = True) -> Union[str, List[str]]: ...
|
||||||
|
|
||||||
def new_tab(self, url: str = None, switch_to: bool = False) -> str: ...
|
def _new_tab(self, url: str = None, switch_to: bool = False) -> str: ...
|
||||||
|
|
||||||
|
def new_tab(self, url: str = None, switch_to: bool = False) -> ChromiumTab: ...
|
||||||
|
|
||||||
def to_main_tab(self) -> None: ...
|
def to_main_tab(self) -> None: ...
|
||||||
|
|
||||||
|
@ -374,8 +374,15 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
|||||||
:param tab_id: 要获取的标签页id,为None时获取当前tab
|
:param tab_id: 要获取的标签页id,为None时获取当前tab
|
||||||
:return: 标签页对象
|
:return: 标签页对象
|
||||||
"""
|
"""
|
||||||
tab_id = tab_id or self.tab_id
|
return tab_id if isinstance(tab_id, WebPageTab) else WebPageTab(self, tab_id or self.tab_id)
|
||||||
return WebPageTab(self, tab_id)
|
|
||||||
|
def new_tab(self, url=None, switch_to=False):
|
||||||
|
"""新建一个标签页,该标签页在最后面
|
||||||
|
:param url: 新标签页跳转到的网址
|
||||||
|
:param switch_to: 新建标签页后是否把焦点移过去
|
||||||
|
:return: 新标签页对象
|
||||||
|
"""
|
||||||
|
return WebPageTab(self, self._new_tab(url, switch_to))
|
||||||
|
|
||||||
def close_driver(self):
|
def close_driver(self):
|
||||||
"""关闭driver及浏览器"""
|
"""关闭driver及浏览器"""
|
||||||
@ -424,5 +431,3 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
|||||||
super(SessionPage, self).quit()
|
super(SessionPage, self).quit()
|
||||||
self._tab_obj = None
|
self._tab_obj = None
|
||||||
self._has_driver = None
|
self._has_driver = None
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,7 +124,9 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
|||||||
def get_cookies(self, as_dict: bool = False, all_domains: bool = False,
|
def get_cookies(self, as_dict: bool = False, all_domains: bool = False,
|
||||||
all_info: bool = False) -> Union[dict, list]: ...
|
all_info: bool = False) -> Union[dict, list]: ...
|
||||||
|
|
||||||
def get_tab(self, tab_id: str = None) -> WebPageTab: ...
|
def get_tab(self, tab_id: Union[str, WebPageTab] = None) -> WebPageTab: ...
|
||||||
|
|
||||||
|
def new_tab(self, url: str = None, switch_to: bool = False) -> WebPageTab: ...
|
||||||
|
|
||||||
def close_driver(self) -> None: ...
|
def close_driver(self) -> None: ...
|
||||||
|
|
||||||
@ -165,5 +167,3 @@ class WebPage(SessionPage, ChromiumPage, BasePage):
|
|||||||
def quit(self) -> None: ...
|
def quit(self) -> None: ...
|
||||||
|
|
||||||
def _on_download_begin(self, **kwargs): ...
|
def _on_download_begin(self, **kwargs): ...
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user