MCPcopy Create free account
hub / github.com/seleniumbase/SeleniumBase / is_cdp_swap_needed

Function is_cdp_swap_needed

seleniumbase/fixtures/shared_utils.py:158–171  ·  view source on GitHub ↗

When someone is using CDP Mode with a disconnected webdriver, but they forget to reconnect before calling a webdriver method, this method is used to substitute the webdriver method for a CDP Mode method instead, which keeps CDP Stealth Mode enabled. For other webdriver methods,

(driver)

Source from the content-addressed store, hash-verified

156
157
158def is_cdp_swap_needed(driver):
159 """
160 When someone is using CDP Mode with a disconnected webdriver,
161 but they forget to reconnect before calling a webdriver method,
162 this method is used to substitute the webdriver method for a
163 CDP Mode method instead, which keeps CDP Stealth Mode enabled.
164 For other webdriver methods, SeleniumBase will reconnect first.
165 """
166 return (
167 hasattr(driver, "is_cdp_mode_active")
168 and driver.is_cdp_mode_active()
169 and hasattr(driver, "is_connected")
170 and not driver.is_connected()
171 )
172
173
174def is_chrome_130_or_newer(self, binary_location=None):

Callers

nothing calls this directly

Calls 2

is_cdp_mode_activeMethod · 0.80
is_connectedMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…