Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ with SB(uc=True, test=True, locale="en") as sb:
from seleniumbase import sb_cdp

url = "https://gitlab.com/users/sign_in"
sb = sb_cdp.Chrome(url)
sb.sleep(2.5)
sb = sb_cdp.Chrome(url, incognito=True)
sb.sleep(2)
sb.solve_captcha()
sb.highlight('h1:contains("GitLab")')
sb.highlight('button:contains("Sign in")')
Expand Down
10 changes: 5 additions & 5 deletions examples/cdp_mode/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,17 @@ from seleniumbase import SB
with SB(uc=True, test=True, locale="en", ad_block=True) as sb:
url = "https://www.pokemon.com/us"
sb.activate_cdp_mode(url)
sb.sleep(3.2)
sb.sleep(3.5)
sb.click_if_visible("button#onetrust-accept-btn-handler")
sb.sleep(1.2)
sb.click("a span.icon_pokeball")
sb.sleep(2.5)
sb.click('b:contains("Show Advanced Search")')
sb.sleep(2.5)
sb.click('span[data-type="type"][data-value="electric"]')
sb.sleep(0.5)
sb.sleep(0.7)
sb.scroll_into_view("a#advSearch")
sb.sleep(0.5)
sb.sleep(0.7)
sb.click("a#advSearch")
sb.sleep(1.2)
sb.click('img[src*="img/pokedex/detail/025.png"]')
Expand Down Expand Up @@ -234,10 +234,10 @@ with SB(uc=True, test=True, locale="en") as sb:
```python
from seleniumbase import SB

with SB(uc=True, test=True, locale="en", ad_block=True) as sb:
with SB(uc=True, test=True, locale="en", guest=True) as sb:
url = "https://www.bestwestern.com/en_US.html"
sb.activate_cdp_mode(url)
sb.sleep(2.5)
sb.sleep(3)
sb.click_if_visible(".onetrust-close-btn-handler")
sb.sleep(1)
sb.click("input#destination-input")
Expand Down
2 changes: 1 addition & 1 deletion examples/cdp_mode/raw_ahrefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
sb.type(input_field, "github.com/seleniumbase/SeleniumBase")
sb.scroll_down(36)
sb.click(submit_button)
sb.sleep(1)
sb.sleep(2)
sb.solve_captcha()
sb.sleep(3)
sb.wait_for_text_not_visible("Checking", timeout=15)
Expand Down
4 changes: 2 additions & 2 deletions examples/cdp_mode/raw_bestwestern.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from seleniumbase import SB

with SB(uc=True, test=True, locale="en", ad_block=True) as sb:
with SB(uc=True, test=True, locale="en", guest=True) as sb:
url = "https://www.bestwestern.com/en_US.html"
sb.activate_cdp_mode(url)
sb.sleep(2.5)
sb.sleep(3)
sb.click_if_visible(".onetrust-close-btn-handler")
sb.sleep(1)
sb.click("input#destination-input")
Expand Down
2 changes: 1 addition & 1 deletion examples/cdp_mode/raw_cdp_copilot.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from seleniumbase import sb_cdp

url = "https://copilot.microsoft.com/"
sb = sb_cdp.Chrome(url, locale="en")
sb = sb_cdp.Chrome(url, locale="en", guest=True)
textarea = "textarea#userInput"
sb.wait_for_element(textarea)
sb.sleep(1.5)
Expand Down
1 change: 1 addition & 0 deletions examples/cdp_mode/raw_cdp_gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

url = "https://gitlab.com/users/sign_in"
sb = sb_cdp.Chrome(url, incognito=True)
sb.sleep(2)
sb.solve_captcha()
sb.highlight('h1:contains("GitLab")')
sb.highlight('button:contains("Sign in")')
Expand Down
4 changes: 2 additions & 2 deletions examples/cdp_mode/raw_cf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
with SB(uc=True, test=True, locale="en", guest=True) as sb:
url = "https://www.cloudflare.com/login"
sb.activate_cdp_mode(url)
sb.sleep(3)
sb.sleep(4)
sb.uc_gui_handle_captcha() # PyAutoGUI press Tab and Spacebar
sb.sleep(2)

with SB(uc=True, test=True, locale="en", guest=True) as sb:
url = "https://www.cloudflare.com/login"
sb.activate_cdp_mode(url)
sb.sleep(3)
sb.sleep(4)
sb.uc_gui_click_captcha() # PyAutoGUI click. (Linux needs it)
sb.sleep(2)
1 change: 1 addition & 0 deletions examples/cdp_mode/raw_gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
with SB(uc=True, test=True, locale="en") as sb:
url = "https://gitlab.com/users/sign_in"
sb.activate_cdp_mode(url)
sb.sleep(2)
sb.solve_captcha()
# (The rest is for testing and demo purposes)
sb.assert_text("Username", '[for="user_login"]', timeout=3)
Expand Down
2 changes: 1 addition & 1 deletion examples/cdp_mode/raw_glassdoor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
with SB(uc=True, test=True, ad_block=True) as sb:
url = "https://www.glassdoor.com/Reviews/index.htm"
sb.activate_cdp_mode(url)
sb.sleep(1.2)
sb.sleep(1.5)
sb.solve_captcha()
sb.highlight('[data-test="global-nav-glassdoor-logo"]')
sb.highlight('[data-test="site-header-companies"]')
Expand Down
5 changes: 4 additions & 1 deletion examples/cdp_mode/raw_kohls.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from seleniumbase import SB

with SB(uc=True, test=True, locale="en", ad_block=True) as sb:
with SB(uc=True, test=True, locale="en", incognito=True) as sb:
url = "https://www.kohls.com/"
sb.activate_cdp_mode(url)
sb.sleep(2.6)
search = "Mickey Mouse Blanket"
req_1 = "Mickey"
req_2 = "Blanket"
if not sb.is_element_present('input[name="search"]'):
sb.refresh()
sb.sleep(2.6)
sb.press_keys('input[name="search"]', search + "\n")
sb.sleep(5)
item_selector = 'div[data-testid*="wallet-wrapper"]'
Expand Down
2 changes: 1 addition & 1 deletion examples/cdp_mode/raw_planetmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
with SB(uc=True, test=True, guest=True) as sb:
url = "www.planetminecraft.com/account/sign_in/"
sb.activate_cdp_mode(url)
sb.sleep(1.2)
sb.sleep(2.5)
sb.solve_captcha()
sb.wait_for_element_absent("input[disabled]")
sb.sleep(2)
8 changes: 4 additions & 4 deletions examples/cdp_mode/raw_pokemon.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
from seleniumbase import SB

with SB(uc=True, test=True, locale="en", ad_block=True) as sb:
with SB(uc=True, test=True, locale="en", guest=True) as sb:
url = "https://www.pokemon.com/us"
sb.activate_cdp_mode(url)
sb.sleep(3.2)
sb.sleep(3.5)
sb.click_if_visible("button#onetrust-accept-btn-handler")
sb.sleep(1.2)
sb.click("a span.icon_pokeball")
sb.sleep(2.5)
sb.click('b:contains("Show Advanced Search")')
sb.sleep(2.5)
sb.click('span[data-type="type"][data-value="electric"]')
sb.sleep(0.5)
sb.sleep(0.7)
sb.scroll_into_view("a#advSearch")
sb.sleep(0.5)
sb.sleep(0.7)
sb.click("a#advSearch")
sb.sleep(1.2)
sb.click('img[src*="img/pokedex/detail/025.png"]')
Expand Down
2 changes: 1 addition & 1 deletion examples/cdp_mode/raw_seatgeek.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from seleniumbase import SB

with SB(uc=True, test=True, guest=True) as sb:
with SB(uc=True, test=True, ad_block=True) as sb:
url = "https://seatgeek.com/"
sb.activate_cdp_mode(url)
input_field = 'input[name="search"]'
Expand Down
2 changes: 1 addition & 1 deletion examples/cdp_mode/raw_wsform.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
with SB(uc=True, test=True, locale="en", incognito=True) as sb:
url = "https://wsform.com/demo/"
sb.activate_cdp_mode(url)
sb.sleep(1)
sb.sleep(2)
sb.scroll_into_view("div.grid")
sb.uc_gui_click_captcha()
sb.sleep(2)
18 changes: 10 additions & 8 deletions examples/presenter/uc_presentation_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,16 +463,18 @@ def test_presentation_4(self):
with SB(uc=True, test=True, locale="en", ad_block=True) as sb:
url = "https://www.pokemon.com/us"
sb.activate_cdp_mode(url)
sb.sleep(3.2)
sb.cdp.click("button#onetrust-accept-btn-handler")
sb.sleep(3.5)
sb.click_if_visible("button#onetrust-accept-btn-handler")
sb.sleep(1.2)
sb.cdp.click("a span.icon_pokeball")
sb.click("a span.icon_pokeball")
sb.sleep(2.5)
sb.cdp.click('b:contains("Show Advanced Search")')
sb.click('b:contains("Show Advanced Search")')
sb.sleep(2.5)
sb.cdp.click('span[data-type="type"][data-value="electric"]')
sb.sleep(0.5)
sb.click('span[data-type="type"][data-value="electric"]')
sb.sleep(0.7)
sb.scroll_into_view("a#advSearch")
sb.sleep(0.7)
sb.click("a#advSearch")
sb.sleep(0.5)
sb.cdp.click("a#advSearch")
sb.sleep(1.2)
Expand Down Expand Up @@ -720,10 +722,10 @@ def test_presentation_4(self):
)
self.begin_presentation(filename="uc_presentation.html")

with SB(uc=True, test=True, locale="en", ad_block=True) as sb:
with SB(uc=True, test=True, locale="en", guest=True) as sb:
url = "https://www.bestwestern.com/en_US.html"
sb.activate_cdp_mode(url)
sb.sleep(2.5)
sb.sleep(3)
sb.click_if_visible(".onetrust-close-btn-handler")
sb.sleep(1)
sb.click("input#destination-input")
Expand Down
4 changes: 2 additions & 2 deletions examples/raw_cf.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""SB Manager using CDP Mode for bypassing CAPTCHAs."""
from seleniumbase import SB

with SB(uc=True, test=True, locale="en") as sb:
with SB(uc=True, test=True, locale="en", guest=True) as sb:
url = "https://www.cloudflare.com/login"
sb.activate_cdp_mode(url)
sb.sleep(3.5)
sb.sleep(4)
sb.solve_captcha()
sb.sleep(2.5)
6 changes: 5 additions & 1 deletion examples/raw_games.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
"""SB Manager using CDP Mode for evading bot-detection."""
from seleniumbase import SB

with SB(uc=True, test=True) as sb:
with SB(uc=True, test=True, disable_csp=True) as sb:
url = "https://steamdb.info/"
sb.activate_cdp_mode(url)
sb.sleep(1)
sb.click("a.header-login span")
sb.sleep(2)
sb.solve_captcha()
sb.assert_text("Sign in", "button#js-sign-in", timeout=4)
sb.sleep(0.5)
sb.click("button#js-sign-in")
sb.sleep(0.5)
sb.highlight("div.page_content form")
sb.highlight('button:contains("Sign in")', scroll=False)
sb.set_messenger_theme(location="top_center")
sb.post_message("SeleniumBase wasn't detected", duration=4)
2 changes: 1 addition & 1 deletion examples/raw_gitlab.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from seleniumbase import SB

with SB(uc=True, test=True) as sb:
with SB(uc=True, test=True, locale="en") as sb:
url = "https://gitlab.com/users/sign_in"
sb.activate_cdp_mode(url)
sb.sleep(2)
Expand Down
2 changes: 1 addition & 1 deletion examples/raw_order_tickets.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from seleniumbase import SB

with SB(uc=True, test=True, guest=True) as sb:
with SB(uc=True, test=True, ad_block=True) as sb:
url = "https://www.ticketmaster.com"
sb.activate_cdp_mode(url)
input_field = 'input[name="q"]'
Expand Down
1 change: 1 addition & 0 deletions examples/test_scrape_bing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def test_scrape_bing(self):
self.skip("Skipping test in multi-threaded mode.")
self.open("www.bing.com/search?q=SeleniumBase+GitHub&qs=n&form=QBRE")
self.wait_for_element("main h2 a")
self.sleep(0.5)
soup = self.get_beautiful_soup()
titles = [item.text for item in soup.select("main h2 a")]
print("\nSearch Result Headers:")
Expand Down
2 changes: 1 addition & 1 deletion mkdocs_build/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pymdown-extensions>=10.17.1
pipdeptree>=2.30.0
python-dateutil>=2.8.2
Markdown==3.10
click==8.3.0
click==8.3.1
ghp-import==2.1.0
watchdog==6.0.0
cairocffi==1.7.1
Expand Down
2 changes: 1 addition & 1 deletion seleniumbase/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# seleniumbase package
__version__ = "4.44.12"
__version__ = "4.44.13"
10 changes: 10 additions & 0 deletions seleniumbase/core/browser_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,12 @@ def uc_execute_cdp_cmd(driver, *args, **kwargs):
return driver.default_execute_cdp_cmd(*args, **kwargs)


def updated_get(driver, url):
if url and ":" not in url and "." in url:
url = "https:" + url
driver.default_get(url)


def uc_special_open_if_cf(
driver,
url,
Expand All @@ -479,6 +485,8 @@ def uc_special_open_if_cf(
device_height=None,
device_pixel_ratio=None,
):
if url and ":" not in url and "." in url:
url = "https:" + url
if url.startswith("http:") or url.startswith("https:"):
special = False
with suppress(Exception):
Expand Down Expand Up @@ -5938,6 +5946,8 @@ def get_local_driver(
'Emulation.setDeviceMetricsOverride',
set_device_metrics_override
)
else:
driver.get = lambda url: updated_get(driver, url)
return extend_driver(
driver, proxy_auth, use_uc, recorder_ext
)
Expand Down
12 changes: 6 additions & 6 deletions seleniumbase/core/detect_b_ver.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,19 +360,19 @@ def comet_on_windows_path(browser_type=None):
for item in map(
os.environ.get,
(
"LOCALAPPDATA",
"PROGRAMFILES",
"PROGRAMFILES(X86)",
"LOCALAPPDATA",
"PROGRAMW6432",
),
):
for subitem in (
"Perplexity/Comet/Application"
"Perplexity/Comet/Application",
"Comet/Application",
"Programs/Comet",
):
try:
candidates.append(os.sep.join((item, subitem, "Comet.exe")))
candidates.append(os.sep.join((item, subitem, "comet.exe")))
except TypeError:
pass
for candidate in candidates:
Expand All @@ -390,19 +390,19 @@ def atlas_on_windows_path(browser_type=None):
for item in map(
os.environ.get,
(
"LOCALAPPDATA",
"PROGRAMFILES",
"PROGRAMFILES(X86)",
"LOCALAPPDATA",
"PROGRAMW6432",
),
):
for subitem in (
"OpenAI/Atlas/Application"
"OpenAI/Atlas/Application",
"Atlas/Application",
"Programs/Atlas",
):
try:
candidates.append(os.sep.join((item, subitem, "Atlas.exe")))
candidates.append(os.sep.join((item, subitem, "atlas.exe")))
except TypeError:
pass
for candidate in candidates:
Expand Down
9 changes: 5 additions & 4 deletions seleniumbase/fixtures/js_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,15 +914,16 @@ def set_messenger_theme(
% (max_messages, messenger_location, theme)
)
try:
time.sleep(0.015)
execute_script(driver, msg_style)
except Exception:
time.sleep(0.03)
time.sleep(0.035)
activate_messenger(driver)
time.sleep(0.15)
time.sleep(0.175)
with suppress(Exception):
execute_script(driver, msg_style)
time.sleep(0.02)
time.sleep(0.05)
time.sleep(0.035)
time.sleep(0.055)


def post_message(driver, message, msg_dur=None, style="info"):
Expand Down
Loading