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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ for element in elements:
<p>💡 You can set the Chromium browser to use via command line parameters:</p>

```zsh
python SCRIPT.py --use-chromium # Use the unbranded Chromium browser
python SCRIPT.py --chromium # Use the unbranded Chromium browser
python SCRIPT.py --cft # Use Chrome-for-testing
python SCRIPT.py --edge # Use Microsoft Edge
python SCRIPT.py --brave # Use Brave browser
Expand Down
6 changes: 2 additions & 4 deletions examples/cdp_mode/playwright/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ async def main():
await page.goto("https://example.com")

if __name__ == "__main__":
loop = asyncio.new_event_loop()
loop.run_until_complete(main())
asyncio.run(main())
```

### 💡 Key differences of the 3 stealthy formats:
Expand Down Expand Up @@ -269,8 +268,7 @@ async def main():
# ...

if __name__ == "__main__":
loop = asyncio.new_event_loop()
loop.run_until_complete(main())
asyncio.run(main())
```

(Fill in the `url` and the `proxy` details to complete the script.)
Expand Down
3 changes: 1 addition & 2 deletions examples/cdp_mode/playwright/raw_basic_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ async def main():


if __name__ == "__main__":
loop = asyncio.new_event_loop()
loop.run_until_complete(main())
asyncio.run(main())
3 changes: 1 addition & 2 deletions examples/cdp_mode/playwright/raw_bing_cap_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ async def main():


if __name__ == "__main__":
loop = asyncio.new_event_loop()
loop.run_until_complete(main())
asyncio.run(main())
3 changes: 1 addition & 2 deletions examples/cdp_mode/playwright/raw_copilot_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ async def main():


if __name__ == "__main__":
loop = asyncio.new_event_loop()
loop.run_until_complete(main())
asyncio.run(main())
3 changes: 1 addition & 2 deletions examples/cdp_mode/playwright/raw_gas_info_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,4 @@ async def main():


if __name__ == "__main__":
loop = asyncio.new_event_loop()
loop.run_until_complete(main())
asyncio.run(main())
3 changes: 1 addition & 2 deletions examples/cdp_mode/playwright/raw_gitlab_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ async def main():


if __name__ == "__main__":
loop = asyncio.new_event_loop()
loop.run_until_complete(main())
asyncio.run(main())
3 changes: 1 addition & 2 deletions examples/cdp_mode/playwright/raw_yc_news_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ async def main():


if __name__ == "__main__":
loop = asyncio.new_event_loop()
loop.run_until_complete(main())
asyncio.run(main())
3 changes: 1 addition & 2 deletions examples/cdp_mode/raw_basic_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@ async def main():
driver.quit()

if __name__ == "__main__":
loop = asyncio.new_event_loop()
with decorators.print_runtime("raw_basic_async.py"):
loop.run_until_complete(main())
asyncio.run(main())
4 changes: 2 additions & 2 deletions examples/cdp_mode/raw_hilton.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
location_input = "input#location-input"
sb.wait_for_element(location_input)
sb.sleep(1.2)
sb.click("input#location-input")
sb.click(location_input)
sb.sleep(1.2)
sb.press_keys("input#location-input", location)
sb.press_keys(location_input, location)
sb.sleep(2)
sb.click('span:contains("Check-in")')
sb.sleep(1.2)
Expand Down
3 changes: 1 addition & 2 deletions examples/cdp_mode/raw_mobile_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@ async def main():
driver.stop()

if __name__ == "__main__":
loop = asyncio.new_event_loop()
with decorators.print_runtime("raw_mobile_async.py"):
loop.run_until_complete(main())
asyncio.run(main())
7 changes: 3 additions & 4 deletions examples/cdp_mode/raw_multi_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ async def main(url):
driver.stop()


def set_up_loop(url):
loop = asyncio.new_event_loop()
loop.run_until_complete(main(url))
def run_main(url):
asyncio.run(main(url))


if __name__ == "__main__":
urls = ["https://seleniumbase.io/demo_page" for i in range(5)]
with decorators.print_runtime("raw_multi_async.py"):
with ThreadPoolExecutor(max_workers=len(urls)) as executor:
for url in urls:
executor.submit(set_up_loop, url)
executor.submit(run_main, url)
7 changes: 3 additions & 4 deletions examples/cdp_mode/raw_multi_c_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ async def main(url):
driver.stop()


def set_up_loop(url):
loop = asyncio.new_event_loop()
loop.run_until_complete(main(url))
def run_main(url):
asyncio.run(main(url))


if __name__ == "__main__":
urls = ["https://seleniumbase.io/apps/turnstile" for i in range(4)]
with decorators.print_runtime("raw_multi_c_async.py"):
with ThreadPoolExecutor(max_workers=len(urls)) as executor:
for url in urls:
executor.submit(set_up_loop, url)
executor.submit(run_main, url)
3 changes: 1 addition & 2 deletions examples/cdp_mode/raw_muse_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ async def main():
await page.sleep(3)

if __name__ == "__main__":
loop = asyncio.new_event_loop()
loop.run_until_complete(main())
asyncio.run(main())
4 changes: 1 addition & 3 deletions examples/cdp_mode/raw_priceline.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
sb.activate_cdp_mode()
sb.goto("https://www.priceline.com")
sb.sleep(3)
input_selector = 'input[name="endLocation"]'
if not sb.is_element_present(input_selector):
input_selector = "div.location-input input"
input_selector = "div.location-input input"
sb.gui_hover_element(input_selector)
sb.mouse_click(input_selector)
location = "Portland, OR"
Expand Down
3 changes: 1 addition & 2 deletions examples/cdp_mode/raw_reddit_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,4 @@ async def main():
driver.stop()

if __name__ == "__main__":
loop = asyncio.new_event_loop()
loop.run_until_complete(main())
asyncio.run(main())
3 changes: 1 addition & 2 deletions examples/cdp_mode/raw_req_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ async def start_test(self):
@decorators.print_runtime("RequestPausedTest")
def main():
test = RequestPausedTest()
loop = asyncio.new_event_loop()
loop.run_until_complete(test.start_test())
asyncio.run(test.start_test())


if __name__ == "__main__":
Expand Down
8 changes: 3 additions & 5 deletions examples/cdp_mode/raw_stopandshop.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
with SB(uc=True, test=True, guest=True) as sb:
sb.activate_cdp_mode()
sb.goto("https://stopandshop.com/")
sb.sleep(2.8)
if not sb.is_element_present("#brand-logo_link"):
sb.refresh()
sb.sleep(2.6)
sb.wait_for_element("#brand-logo_link", timeout=3)
sb.sleep(1.6)
sb.solve_captcha()
sb.sleep(1.8)
sb.click_if_visible("#optly-popup-refresh-btn")
query = "Fresh Turkey"
required_text = "Turkey"
Expand Down
2 changes: 1 addition & 1 deletion mkdocs_build/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ regex>=2026.5.9
pymdown-extensions>=10.21.3
pipdeptree>=3.1.0
python-dateutil>=2.8.2
click>=8.4.1
click>=8.4.2
Markdown==3.10.2
ghp-import==2.1.0
watchdog==6.0.0
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.50.2"
__version__ = "4.50.3"
7 changes: 5 additions & 2 deletions seleniumbase/behave/behave_sb.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,11 @@ def get_configured_sb(context):
sb.binary_location = binary_location
sb_config.binary_location = binary_location
continue
# Handle: -D use-chromium
if low_key in ["use-chromium"] and not sb_config.binary_location:
# Handle: -D use-chromium / chromium
if (
low_key in ["use-chromium", "chromium"]
and not sb_config.binary_location
):
binary_location = "_chromium_"
sb.binary_location = binary_location
sb_config.binary_location = binary_location
Expand Down
7 changes: 4 additions & 3 deletions seleniumbase/console_scripts/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,14 @@ sbase install [DRIVER] [OPTIONS]
sbase get chromedriver
sbase get geckodriver
sbase get edgedriver
sbase get chromedriver 114
sbase get chromedriver 114.0.5735.90
sbase get chromedriver 149
sbase get chromedriver 149.0.7827.115
sbase get chromedriver stable
sbase get chromedriver beta
sbase get chromedriver -p
sbase get chromium
sbase get cft 131
sbase get chromium --revision=1639046
sbase get cft 149
sbase get chs
```

Expand Down
8 changes: 5 additions & 3 deletions seleniumbase/console_scripts/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,14 @@ def show_install_usage():
print(" sbase get chromedriver")
print(" sbase get geckodriver")
print(" sbase get edgedriver")
print(" sbase get chromedriver 114")
print(" sbase get chromedriver 114.0.5735.90")
print(" sbase get chromedriver 149")
print(" sbase get chromedriver 149.0.7827.115")
print(" sbase get chromedriver stable")
print(" sbase get chromedriver beta")
print(" sbase get chromedriver -p")
print(" sbase get cft 131")
print(" sbase get chromium")
print(" sbase get chromium --revision=1639046")
print(" sbase get cft 149")
print(" sbase get chs")
print(" Output:")
print(" Downloads the webdriver to seleniumbase/drivers/")
Expand Down
7 changes: 4 additions & 3 deletions seleniumbase/console_scripts/sb_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
sbase get chromedriver
sbase get geckodriver
sbase get edgedriver
sbase get chromedriver 114
sbase get chromedriver 114.0.5735.90
sbase get chromedriver 149
sbase get chromedriver 149.0.7827.115
sbase get chromedriver stable
sbase get chromedriver beta
sbase get chromedriver -p
sbase get chromium
sbase get cft 131
sbase get chromium --revision=1639046
sbase get cft 149
sbase get chs
Output:
Downloads the webdriver to seleniumbase/drivers/
Expand Down
5 changes: 4 additions & 1 deletion seleniumbase/core/browser_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -5012,7 +5012,10 @@ def get_local_driver(
device_height,
device_pixel_ratio,
)
if binary_location and "chromium_drivers" in binary_location:
if (
(binary_location and "chromium_drivers" in binary_location)
or (binary_location and "Chromium.app" in binary_location)
):
chrome_options.add_argument("--use-mock-keychain")
use_version = "latest"
major_chrome_version = None
Expand Down
2 changes: 2 additions & 0 deletions seleniumbase/core/sb_cdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2308,6 +2308,8 @@ def __gui_slide_datadome_captcha(self):
time.sleep(0.48)
self.loop.run_until_complete(self.page.wait(0.1))
x2 = x2 + 22.5 # Overshoot drop to maximize compatibility
y1 = y1 + 3
y2 = y2 + 3
self.gui_drag_drop_points(x1, y1, x2, y2, timeframe=0.55)
time.sleep(0.25)
self.loop.run_until_complete(self.page.wait(0.2))
Expand Down
5 changes: 4 additions & 1 deletion seleniumbase/plugins/driver_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,10 @@ def Driver(
binary_location = "cft"
elif chs and not binary_location:
binary_location = "chs"
if "--use-chromium" in sys_argv and not binary_location:
if (
("--use-chromium" in sys_argv and not binary_location)
or ("--chromium" in sys_argv and not binary_location)
):
binary_location = "_chromium_"
elif "--cft" in sys_argv and not binary_location:
binary_location = "cft"
Expand Down
3 changes: 2 additions & 1 deletion seleniumbase/plugins/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def pytest_addoption(parser):
--brave (Shortcut for "--browser=brave".)
--comet (Shortcut for "--browser=comet".)
--atlas (Shortcut for "--browser=atlas".)
--use-chromium (Shortcut for using base `Chromium`)
--chromium (Shortcut for using base `Chromium`)
--cft (Shortcut for using `Chrome for Testing`)
--chs (Shortcut for using `Chrome-Headless-Shell`)
--settings-file=FILE (Override default SeleniumBase settings.)
Expand Down Expand Up @@ -223,6 +223,7 @@ def pytest_addoption(parser):
)
parser.addoption(
"--use-chromium",
"--chromium",
action="store_true",
dest="use_chromium",
default=False,
Expand Down
5 changes: 4 additions & 1 deletion seleniumbase/plugins/sb_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,10 @@ def SB(
binary_location = "cft"
elif chs and not binary_location:
binary_location = "chs"
if "--use-chromium" in sys_argv and not binary_location:
if (
("--use-chromium" in sys_argv and not binary_location)
or ("--chromium" in sys_argv and not binary_location)
):
binary_location = "_chromium_"
elif "--cft" in sys_argv and not binary_location:
binary_location = "cft"
Expand Down
3 changes: 2 additions & 1 deletion seleniumbase/plugins/selenium_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SeleniumBrowser(Plugin):
--brave (Shortcut for "--browser=brave".)
--comet (Shortcut for "--browser=comet".)
--atlas (Shortcut for "--browser=atlas".)
--use-chromium (Shortcut for using base `Chromium`)
--chromium (Shortcut for using base `Chromium`)
--cft (Shortcut for using `Chrome for Testing`)
--chs (Shortcut for using `Chrome-Headless-Shell`)
--user-data-dir=DIR (Set the Chrome user data directory to use.)
Expand Down Expand Up @@ -184,6 +184,7 @@ def options(self, parser, env):
)
parser.addoption(
"--use-chromium",
"--chromium",
action="store_true",
dest="use_chromium",
default=False,
Expand Down
6 changes: 5 additions & 1 deletion seleniumbase/undetected/cdp_driver/cdp_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,11 @@ async def start(
print(" Using default Chrome browser instead!")
bin_loc = None
browser_executable_path = bin_loc
elif use_chromium or "--use-chromium" in arg_join:
elif (
use_chromium
or "--use-chromium" in arg_join
or "--chromium" in sys_argv
):
browser_executable_path = "_chromium_"
elif cft or "--cft" in arg_join:
browser_executable_path = "_cft_"
Expand Down
2 changes: 2 additions & 0 deletions seleniumbase/undetected/cdp_driver/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ def __init__(
f"Defaulting to regular Chrome!"
)
browser_executable_path = find_chrome_executable()
elif "Chromium.app" in browser_executable_path:
mock_keychain = True
self._browser_args = browser_args
self.browser_executable_path = browser_executable_path
self.headless = headless
Expand Down