mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
优化等待逻辑
This commit is contained in:
parent
f4c76a2c2c
commit
fe2ca2d8c3
@ -362,8 +362,12 @@ class DriverElement(DrissionElement):
|
|||||||
if not by_js:
|
if not by_js:
|
||||||
timeout = timeout if timeout is not None else self.page.timeout
|
timeout = timeout if timeout is not None else self.page.timeout
|
||||||
t1 = perf_counter()
|
t1 = perf_counter()
|
||||||
while not do_it() and perf_counter() - t1 <= timeout:
|
click = do_it()
|
||||||
pass
|
while not click and perf_counter() - t1 <= timeout:
|
||||||
|
click = do_it()
|
||||||
|
|
||||||
|
if click:
|
||||||
|
return True
|
||||||
|
|
||||||
# 若点击失败,用js方式点击
|
# 若点击失败,用js方式点击
|
||||||
if by_js is not False:
|
if by_js is not False:
|
||||||
|
@ -144,15 +144,10 @@ class ShadowRootElement(BaseElement):
|
|||||||
loc = loc[0], loc[1][5:]
|
loc = loc[0], loc[1][5:]
|
||||||
|
|
||||||
timeout = timeout if timeout is not None else self.page.timeout
|
timeout = timeout if timeout is not None else self.page.timeout
|
||||||
eles = make_session_ele(self.html).eles(loc)
|
|
||||||
|
|
||||||
t1 = perf_counter()
|
t1 = perf_counter()
|
||||||
|
eles = make_session_ele(self.html).eles(loc)
|
||||||
while not eles and perf_counter() - t1 <= timeout:
|
while not eles and perf_counter() - t1 <= timeout:
|
||||||
try:
|
eles = make_session_ele(self.html).eles(loc)
|
||||||
eles = make_session_ele(self.html).eles(loc)
|
|
||||||
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if not eles:
|
if not eles:
|
||||||
return None if single else eles
|
return None if single else eles
|
||||||
|
Loading…
x
Reference in New Issue
Block a user