Skip to content

Commit f681f46

Browse files
committed
Update CDP Mode
1 parent 02b34f7 commit f681f46

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,6 +1503,10 @@ def is_attribute_present(
15031503
):
15041504
"""Returns True if the element attribute/value is found.
15051505
If the value is not specified, the attribute only needs to exist."""
1506+
if self.__is_cdp_swap_needed():
1507+
return self.cdp.is_attribute_present(
1508+
selector, attribute, value=value
1509+
)
15061510
self.wait_for_ready_state_complete()
15071511
time.sleep(0.01)
15081512
selector, by = self.__recalculate_selector(selector, by)

seleniumbase/fixtures/page_actions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ def is_attribute_present(
193193
@Returns
194194
Boolean (is attribute present)
195195
"""
196+
if __is_cdp_swap_needed(driver):
197+
return driver.cdp.is_attribute_present(
198+
selector, attribute, value=value
199+
)
196200
_reconnect_if_disconnected(driver)
197201
try:
198202
element = driver.find_element(by=by, value=selector)

seleniumbase/undetected/cdp_driver/browser.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@ async def get(
350350
if _cdp_geolocation:
351351
await connection.send(cdp.page.navigate("about:blank"))
352352
await connection.set_geolocation(_cdp_geolocation)
353-
# Use the tab to navigate to new url
353+
# This part isn't needed now, but may be needed later
354+
"""
354355
if (
355356
hasattr(sb_config, "_cdp_proxy")
356357
and "@" in sb_config._cdp_proxy
@@ -360,17 +361,14 @@ async def get(
360361
username_and_password = sb_config._cdp_proxy.split("@")[0]
361362
proxy_user = username_and_password.split(":")[0]
362363
proxy_pass = username_and_password.split(":")[1]
363-
await connection.set_auth(
364-
proxy_user, proxy_pass, self.tabs[0]
365-
)
364+
await connection.set_auth(proxy_user, proxy_pass, self.tabs[0])
366365
time.sleep(0.25)
367-
elif "auth" in kwargs and kwargs["auth"] and ":" in kwargs["auth"]:
366+
"""
367+
if "auth" in kwargs and kwargs["auth"] and ":" in kwargs["auth"]:
368368
username_and_password = kwargs["auth"]
369369
proxy_user = username_and_password.split(":")[0]
370370
proxy_pass = username_and_password.split(":")[1]
371-
await connection.set_auth(
372-
proxy_user, proxy_pass, self.tabs[0]
373-
)
371+
await connection.set_auth(proxy_user, proxy_pass, self.tabs[0])
374372
time.sleep(0.25)
375373
frame_id, loader_id, *_ = await connection.send(
376374
cdp.page.navigate(url)

0 commit comments

Comments
 (0)