Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	DrissionPage/_units/clicker.py
This commit is contained in:
g1879 2024-02-20 17:58:08 +08:00
commit 133cee1e75
2 changed files with 12 additions and 1 deletions

View File

@ -184,6 +184,17 @@ class Clicker(object):
raise RuntimeError('没有出现新标签页。')
return self._ele.page.get_tab(tid)
def for_new_tab(self, by_js=False):
"""点击后等待新tab出现并返回其对象
:param by_js: 是否使用js点击逻辑与click()一致
:return: 新标签页对象如果没有等到新标签页出现则抛出异常
"""
self.left(by_js=by_js)
tid = self._ele.page._page.wait.new_tab()
if not tid:
raise RuntimeError('没有出现新标签页。')
return self._ele.page._page.get_tab(tid)
def _click(self, client_x, client_y, button='left', count=1):
"""实施点击
:param client_x: 视口中的x坐标

View File

@ -123,4 +123,4 @@ python 版本3.6 及以上
如果本项目对您有所帮助,不妨请作者我喝杯咖啡
![](https://gitee.com/g1879/DrissionPageDocs/raw/master/docs/imgs/code.jpg)
![](https://g1879.gitee.io/drissionpagedocs/assets/images/code-cf68de50a2f331a2aa0d39c9aebbbe2c.jpg)