mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
4.0.5.0修复states.is_alive和wait.deleted()问题
This commit is contained in:
parent
b8aa656f45
commit
fb495a99be
@ -14,4 +14,4 @@ from ._configs.chromium_options import ChromiumOptions
|
|||||||
from ._configs.session_options import SessionOptions
|
from ._configs.session_options import SessionOptions
|
||||||
|
|
||||||
__all__ = ['ChromiumPage', 'ChromiumOptions', 'SessionOptions', 'SessionPage', 'WebPage', '__version__']
|
__all__ = ['ChromiumPage', 'ChromiumOptions', 'SessionOptions', 'SessionPage', 'WebPage', '__version__']
|
||||||
__version__ = '4.0.4.25'
|
__version__ = '4.0.5.0'
|
||||||
|
@ -42,9 +42,9 @@ class ElementStates(object):
|
|||||||
def is_alive(self):
|
def is_alive(self):
|
||||||
"""返回元素是否仍在DOM中"""
|
"""返回元素是否仍在DOM中"""
|
||||||
try:
|
try:
|
||||||
self._ele.attrs
|
return self._ele.owner.run_cdp('DOM.describeNode',
|
||||||
return True
|
backendNodeId=self._ele._backend_id)['node']['nodeId'] != 0
|
||||||
except Exception:
|
except ElementLostError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -101,9 +101,9 @@ class ShadowRootStates(object):
|
|||||||
def is_alive(self):
|
def is_alive(self):
|
||||||
"""返回元素是否仍在DOM中"""
|
"""返回元素是否仍在DOM中"""
|
||||||
try:
|
try:
|
||||||
self._ele.owner.run_cdp('DOM.describeNode', backendNodeId=self._ele._backend_id)
|
return self._ele.owner.run_cdp('DOM.describeNode',
|
||||||
return True
|
backendNodeId=self._ele._backend_id)['node']['nodeId'] != 0
|
||||||
except Exception:
|
except ElementLostError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
@ -495,7 +495,7 @@ class ElementWaiter(OriginWaiter):
|
|||||||
"""
|
"""
|
||||||
a = self._ele.states.__getattribute__(attr)
|
a = self._ele.states.__getattribute__(attr)
|
||||||
if (a and mode) or (not a and not mode):
|
if (a and mode) or (not a and not mode):
|
||||||
return a
|
return True if isinstance(a, bool) else a
|
||||||
|
|
||||||
if timeout is None:
|
if timeout is None:
|
||||||
timeout = self._owner.timeout
|
timeout = self._owner.timeout
|
||||||
@ -503,7 +503,7 @@ class ElementWaiter(OriginWaiter):
|
|||||||
while perf_counter() < end_time:
|
while perf_counter() < end_time:
|
||||||
a = self._ele.states.__getattribute__(attr)
|
a = self._ele.states.__getattribute__(attr)
|
||||||
if (a and mode) or (not a and not mode):
|
if (a and mode) or (not a and not mode):
|
||||||
return a
|
return True if isinstance(a, bool) else a
|
||||||
sleep(.05)
|
sleep(.05)
|
||||||
|
|
||||||
err_text = err_text or '等待元素状态改变失败(等待{}秒)。'
|
err_text = err_text or '等待元素状态改变失败(等待{}秒)。'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user