mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-11-29 10:37:35 +08:00
4.1.0.12修复无法处理连续弹框问题;修复新建tab可能出现的问题;指定tldextract版本
This commit is contained in:
parent
7a5cc465db
commit
d6402c26c8
@ -12,4 +12,4 @@ from ._pages.chromium_page import ChromiumPage
|
|||||||
from ._pages.session_page import SessionPage
|
from ._pages.session_page import SessionPage
|
||||||
from ._pages.web_page import WebPage
|
from ._pages.web_page import WebPage
|
||||||
|
|
||||||
__version__ = '4.1.0.11'
|
__version__ = '4.1.0.12'
|
||||||
|
@ -294,7 +294,7 @@ class Chromium(object):
|
|||||||
rmtree(path, True)
|
rmtree(path, True)
|
||||||
|
|
||||||
def _new_tab(self, mix=True, url=None, new_window=False, background=False, new_context=False):
|
def _new_tab(self, mix=True, url=None, new_window=False, background=False, new_context=False):
|
||||||
obj = MixTab if mix else ChromiumTab
|
tab_type = MixTab if mix else ChromiumTab
|
||||||
tab = None
|
tab = None
|
||||||
if new_context:
|
if new_context:
|
||||||
tab = self._run_cdp('Target.createBrowserContext')['browserContextId']
|
tab = self._run_cdp('Target.createBrowserContext')['browserContextId']
|
||||||
@ -308,12 +308,12 @@ class Chromium(object):
|
|||||||
kwargs['browserContextId'] = tab
|
kwargs['browserContextId'] = tab
|
||||||
|
|
||||||
if self.states.is_incognito:
|
if self.states.is_incognito:
|
||||||
return _new_tab_by_js(self, url, obj, new_window)
|
return _new_tab_by_js(self, url, tab_type, new_window)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
tab = self._run_cdp('Target.createTarget', **kwargs)['targetId']
|
tab = self._run_cdp('Target.createTarget', **kwargs)['targetId']
|
||||||
except CDPError:
|
except CDPError:
|
||||||
return _new_tab_by_js(self, url, obj, new_window)
|
return _new_tab_by_js(self, url, tab_type, new_window)
|
||||||
|
|
||||||
while self.states.is_alive:
|
while self.states.is_alive:
|
||||||
if tab in self._drivers:
|
if tab in self._drivers:
|
||||||
@ -321,7 +321,7 @@ class Chromium(object):
|
|||||||
sleep(.1)
|
sleep(.1)
|
||||||
else:
|
else:
|
||||||
raise BrowserConnectError('浏览器已关闭')
|
raise BrowserConnectError('浏览器已关闭')
|
||||||
tab = obj(self, tab)
|
tab = tab_type(self, tab)
|
||||||
if url:
|
if url:
|
||||||
tab.get(url)
|
tab.get(url)
|
||||||
return tab
|
return tab
|
||||||
@ -484,8 +484,8 @@ def run_browser(chromium_options):
|
|||||||
return is_headless, browser_id, is_exists
|
return is_headless, browser_id, is_exists
|
||||||
|
|
||||||
|
|
||||||
def _new_tab_by_js(browser: Chromium, url, obj, new_window):
|
def _new_tab_by_js(browser: Chromium, url, tab_type, new_window):
|
||||||
mix = isinstance(obj, MixTab)
|
mix = tab_type == MixTab
|
||||||
tab = browser._get_tab(mix=mix)
|
tab = browser._get_tab(mix=mix)
|
||||||
if url and not match(r'^.*?://.*', url):
|
if url and not match(r'^.*?://.*', url):
|
||||||
raise ValueError(f'url也许需要加上http://?')
|
raise ValueError(f'url也许需要加上http://?')
|
||||||
|
@ -673,11 +673,11 @@ class ChromiumBase(BasePage):
|
|||||||
self._get_document()
|
self._get_document()
|
||||||
|
|
||||||
def handle_alert(self, accept=True, send=None, timeout=None, next_one=False):
|
def handle_alert(self, accept=True, send=None, timeout=None, next_one=False):
|
||||||
r = self._handle_alert(accept=accept, send=send, timeout=timeout, next_one=next_one)
|
|
||||||
if not isinstance(accept, bool):
|
if not isinstance(accept, bool):
|
||||||
return r
|
return self._handle_alert(accept=accept, send=send, timeout=timeout, next_one=next_one)
|
||||||
|
r = self._handle_alert(accept=accept, send=send, timeout=timeout, next_one=next_one)
|
||||||
while self._has_alert:
|
while self._has_alert:
|
||||||
sleep(.1)
|
sleep(.0001)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def _handle_alert(self, accept=True, send=None, timeout=None, next_one=False):
|
def _handle_alert(self, accept=True, send=None, timeout=None, next_one=False):
|
||||||
|
@ -573,7 +573,10 @@ class ChromiumBase(BasePage):
|
|||||||
"""
|
"""
|
||||||
...
|
...
|
||||||
|
|
||||||
def handle_alert(self, accept: Optional[bool] = True, send: str = None, timeout: float = None,
|
def handle_alert(self,
|
||||||
|
accept: Optional[bool] = True,
|
||||||
|
send: str = None,
|
||||||
|
timeout: float = None,
|
||||||
next_one: bool = False) -> Union[str, False]:
|
next_one: bool = False) -> Union[str, False]:
|
||||||
"""处理提示框,可以自动等待提示框出现
|
"""处理提示框,可以自动等待提示框出现
|
||||||
:param accept: True表示确认,False表示取消,为None不会按按钮但依然返回文本值
|
:param accept: True表示确认,False表示取消,为None不会按按钮但依然返回文本值
|
||||||
@ -584,7 +587,10 @@ class ChromiumBase(BasePage):
|
|||||||
"""
|
"""
|
||||||
...
|
...
|
||||||
|
|
||||||
def _handle_alert(self, accept: bool = True, send: str = None, timeout: float = None,
|
def _handle_alert(self,
|
||||||
|
accept: Optional[bool] = True,
|
||||||
|
send: str = None,
|
||||||
|
timeout: float = None,
|
||||||
next_one: bool = False) -> Union[str, False]:
|
next_one: bool = False) -> Union[str, False]:
|
||||||
"""处理提示框,可以自动等待提示框出现
|
"""处理提示框,可以自动等待提示框出现
|
||||||
:param accept: True表示确认,False表示取消,其它值不会按按钮但依然返回文本值
|
:param accept: True表示确认,False表示取消,其它值不会按按钮但依然返回文本值
|
||||||
|
@ -4,5 +4,5 @@ cssselect
|
|||||||
DownloadKit>=2.0.5
|
DownloadKit>=2.0.5
|
||||||
websocket-client
|
websocket-client
|
||||||
click
|
click
|
||||||
tldextract
|
tldextract>=3.4.4
|
||||||
psutil
|
psutil
|
Loading…
Reference in New Issue
Block a user