Skip to content

Commit e7a3b97

Browse files
committed
Update CDP Mode
1 parent 1ab98f5 commit e7a3b97

3 files changed

Lines changed: 36 additions & 10 deletions

File tree

seleniumbase/core/browser_launcher.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,11 +1501,12 @@ def _uc_gui_click_captcha(
15011501
):
15021502
frame = '[data-callback="onCaptchaSuccess"]'
15031503
elif driver.is_element_present(
1504-
"div:not([class]):not([id]) > div:not([class]):not([id])"
1504+
"div:not([class]):not([id]):not([aria-label]) > "
1505+
"div:not([class]):not([id]):not([aria-label])"
15051506
):
15061507
frame = (
1507-
"div:not([class]):not([id]) > "
1508-
"div:not([class]):not([id])"
1508+
"div:not([class]):not([id]):not([aria-label]) > "
1509+
"div:not([class]):not([id]):not([aria-label])"
15091510
)
15101511
else:
15111512
return False
@@ -1629,7 +1630,7 @@ def _uc_gui_click_captcha(
16291630
y = i_y + element.rect["y"] + (element.rect["height"] / 2.0)
16301631
y += 0.5
16311632
else:
1632-
x = (i_x + 32) * width_ratio
1633+
x = (i_x + 28) * width_ratio
16331634
if not IS_WINDOWS:
16341635
y = (i_y + 32) * width_ratio
16351636
else:

seleniumbase/core/sb_cdp.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2207,10 +2207,12 @@ def __click_captcha(self, use_cdp=False):
22072207
):
22082208
selector = '[data-callback="onCaptchaSuccess"]'
22092209
elif self.is_element_present(
2210-
"div:not([class]):not([id]) > div:not([class]):not([id])"
2210+
"div:not([class]):not([id]):not([aria-label]) > "
2211+
"div:not([class]):not([id]):not([aria-label])"
22112212
):
22122213
selector = (
2213-
"div:not([class]):not([id]) > div:not([class]):not([id])"
2214+
"div:not([class]):not([id]):not([aria-label]) > "
2215+
"div:not([class]):not([id]):not([aria-label])"
22142216
)
22152217
else:
22162218
return False
@@ -2303,7 +2305,7 @@ def __click_captcha(self, use_cdp=False):
23032305
element_rect = self.get_gui_element_rect(selector, timeout=1)
23042306
e_x = element_rect["x"]
23052307
e_y = element_rect["y"]
2306-
x_offset = 32
2308+
x_offset = 28
23072309
y_offset = 32
23082310
if shared_utils.is_windows():
23092311
y_offset = 28

seleniumbase/undetected/cdp_driver/tab.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,24 @@ async def get_navigation_history(self):
672672
"""Get Navigation History"""
673673
return await self.send(cdp.page.get_navigation_history())
674674

675+
async def get_user_agent(self):
676+
"""Get User Agent String"""
677+
return await self.evaluate("navigator.userAgent")
678+
679+
async def get_cookie_string(self):
680+
"""Get Cookie String"""
681+
return await self.evaluate("document.cookie")
682+
683+
async def get_locale_code(self):
684+
"""Get Locale Code"""
685+
return await self.evaluate(
686+
"navigator.language || navigator.languages[0]"
687+
)
688+
689+
async def is_online(self):
690+
"""Determine if connected to the Internet"""
691+
return await self.evaluate("navigator.onLine")
692+
675693
async def reload(
676694
self,
677695
ignore_cache: Optional[bool] = True,
@@ -1577,6 +1595,9 @@ async def get_title(self):
15771595
async def get_current_url(self):
15781596
return await self.evaluate("window.location.href")
15791597

1598+
async def get_origin(self):
1599+
return await self.evaluate("window.location.origin")
1600+
15801601
async def send_keys(self, selector, text, timeout=5):
15811602
element = await self.find(selector, timeout=timeout)
15821603
await element.send_keys_async(text)
@@ -1669,10 +1690,12 @@ async def solve_captcha(self):
16691690
):
16701691
selector = '[data-callback="onCaptchaSuccess"]'
16711692
elif await self.is_element_present(
1672-
"div:not([class]):not([id]) > div:not([class]):not([id])"
1693+
"div:not([class]):not([id]):not([aria-label]) > "
1694+
"div:not([class]):not([id]):not([aria-label])"
16731695
):
16741696
selector = (
1675-
"div:not([class]):not([id]) > div:not([class]):not([id])"
1697+
"div:not([class]):not([id]):not([aria-label]) > "
1698+
"div:not([class]):not([id]):not([aria-label])"
16761699
)
16771700
else:
16781701
return False
@@ -1761,7 +1784,7 @@ async def solve_captcha(self):
17611784
element_rect = await self.get_gui_element_rect(selector, timeout=1)
17621785
e_x = element_rect["x"]
17631786
e_y = element_rect["y"]
1764-
x_offset = 32
1787+
x_offset = 28
17651788
y_offset = 32
17661789
if await asyncio.to_thread(shared_utils.is_windows):
17671790
y_offset = 28

0 commit comments

Comments
 (0)