diff --git a/README.md b/README.md index df37a130..3180e9f3 100755 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ with SB(test=True, uc=True) as sb: ```python from seleniumbase import SB -with SB(uc=True, test=True, locale_code="en") 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.uc_gui_click_captcha() diff --git a/examples/cdp_mode/ReadMe.md b/examples/cdp_mode/ReadMe.md index 48d7c46e..0065d6b4 100644 --- a/examples/cdp_mode/ReadMe.md +++ b/examples/cdp_mode/ReadMe.md @@ -50,7 +50,7 @@ Simple example: ([SeleniumBase/examples/cdp_mode/raw_gitlab.py](https://github.c ```python from seleniumbase import SB -with SB(uc=True, test=True, locale_code="en") 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.uc_gui_click_captcha() @@ -130,7 +130,7 @@ To find out if WebDriver is connected or disconnected, call: ```python from seleniumbase import SB -with SB(uc=True, test=True, locale_code="en", ad_block=True) as 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) @@ -189,7 +189,7 @@ with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb: ```python from seleniumbase import SB -with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb: +with SB(uc=True, test=True, locale="en", ad_block=True) as sb: url = "https://www.hyatt.com/" sb.activate_cdp_mode(url) sb.sleep(2.5) @@ -236,7 +236,7 @@ with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb: ```python from seleniumbase import SB -with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb: +with SB(uc=True, test=True, locale="en", ad_block=True) as sb: url = "https://www.bestwestern.com/en_US.html" sb.activate_cdp_mode(url) sb.sleep(2.5) @@ -328,11 +328,11 @@ with SB(uc=True, test=True, ad_block=True) as sb: ```python from seleniumbase import SB -with SB(uc=True, test=True, locale_code="en", pls="none") as sb: +with SB(uc=True, test=True, locale="en", pls="none") as sb: url = "https://www.nike.com/" sb.activate_cdp_mode(url) sb.sleep(2.5) - sb.cdp.mouse_click('div[data-testid="user-tools-container"]') + sb.cdp.click('div[data-testid="user-tools-container"]') sb.sleep(1.5) search = "Nike Air Force 1" sb.cdp.press_keys('input[type="search"]', search) diff --git a/examples/cdp_mode/raw_ahrefs.py b/examples/cdp_mode/raw_ahrefs.py index 60f5554b..2d634361 100644 --- a/examples/cdp_mode/raw_ahrefs.py +++ b/examples/cdp_mode/raw_ahrefs.py @@ -1,6 +1,6 @@ from seleniumbase import SB -with SB(uc=True, test=True, incognito=True, locale_code="en") as sb: +with SB(uc=True, test=True, incognito=True, locale="en") as sb: url = "https://ahrefs.com/website-authority-checker" input_field = 'input[placeholder="Enter domain"]' submit_button = 'span:contains("Check Authority")' diff --git a/examples/cdp_mode/raw_albertsons.py b/examples/cdp_mode/raw_albertsons.py index 22e07820..0903054c 100644 --- a/examples/cdp_mode/raw_albertsons.py +++ b/examples/cdp_mode/raw_albertsons.py @@ -1,6 +1,6 @@ from seleniumbase import SB -with SB(uc=True, test=True, locale_code="en") as sb: +with SB(uc=True, test=True, locale="en") as sb: url = "https://www.albertsons.com/recipes/" sb.activate_cdp_mode(url) sb.sleep(2.5) diff --git a/examples/cdp_mode/raw_async.py b/examples/cdp_mode/raw_async.py index 77874068..6ed65581 100644 --- a/examples/cdp_mode/raw_async.py +++ b/examples/cdp_mode/raw_async.py @@ -1,15 +1,14 @@ import asyncio import time from contextlib import suppress -from seleniumbase.core import sb_cdp -from seleniumbase.undetected import cdp_driver +from seleniumbase import sb_cdp +from seleniumbase import cdp_driver async def main(): - driver = await cdp_driver.cdp_util.start_async() - page = await driver.get("about:blank") - await page.set_locale("en") - await page.get("https://www.priceline.com/") + url = "https://www.priceline.com/" + driver = await cdp_driver.start_async(lang="en") + page = await driver.get(url) time.sleep(3) print(await page.evaluate("document.title")) element = await page.select('[data-testid*="endLocation"]') @@ -24,7 +23,7 @@ if __name__ == "__main__": loop.run_until_complete(main()) # Call everything without using async / await - driver = cdp_driver.cdp_util.start_sync() + driver = cdp_driver.start_sync() page = loop.run_until_complete(driver.get("about:blank")) loop.run_until_complete(page.set_locale("en")) loop.run_until_complete(page.get("https://www.pokemon.com/us")) @@ -41,11 +40,8 @@ if __name__ == "__main__": print(loop.run_until_complete(page.evaluate("document.title"))) time.sleep(1) - # Call CDP methods via the simplified CDP API - page = loop.run_until_complete(driver.get("about:blank")) - sb = sb_cdp.CDPMethods(loop, page, driver) - sb.set_locale("en") - sb.open("https://www.priceline.com/") + # Call CDP methods via the simplified SB CDP API + sb = sb_cdp.Chrome("https://www.priceline.com/") sb.sleep(2.5) sb.internalize_links() # Don't open links in a new tab sb.click("#link_header_nav_experiences") diff --git a/examples/cdp_mode/raw_bestwestern.py b/examples/cdp_mode/raw_bestwestern.py index 97031634..d22db30b 100644 --- a/examples/cdp_mode/raw_bestwestern.py +++ b/examples/cdp_mode/raw_bestwestern.py @@ -1,6 +1,6 @@ from seleniumbase import SB -with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb: +with SB(uc=True, test=True, locale="en", ad_block=True) as sb: url = "https://www.bestwestern.com/en_US.html" sb.activate_cdp_mode(url) sb.sleep(2.5) diff --git a/examples/cdp_mode/raw_cdp.py b/examples/cdp_mode/raw_cdp.py index c733859c..86c3daa4 100644 --- a/examples/cdp_mode/raw_cdp.py +++ b/examples/cdp_mode/raw_cdp.py @@ -1,20 +1,12 @@ """Example of using CDP Mode without WebDriver""" -import asyncio from seleniumbase import decorators -from seleniumbase.core import sb_cdp -from seleniumbase.undetected import cdp_driver +from seleniumbase import sb_cdp @decorators.print_runtime("CDP Priceline Example") def main(): - url0 = "about:blank" # Set Locale code from here first - url1 = "https://www.priceline.com/" # (The "real" URL) - loop = asyncio.new_event_loop() - driver = cdp_driver.cdp_util.start_sync() - page = loop.run_until_complete(driver.get(url0)) - sb = sb_cdp.CDPMethods(loop, page, driver) - sb.set_locale("en") # This test expects English locale - sb.open(url1) + url = "https://www.priceline.com/" + sb = sb_cdp.Chrome(url, lang="en") sb.sleep(2.5) sb.internalize_links() # Don't open links in a new tab sb.click("#link_header_nav_experiences") diff --git a/examples/cdp_mode/raw_cdp_extended.py b/examples/cdp_mode/raw_cdp_extended.py new file mode 100644 index 00000000..ef3ec48a --- /dev/null +++ b/examples/cdp_mode/raw_cdp_extended.py @@ -0,0 +1,23 @@ +"""The long way of using CDP Mode without WebDriver""" +import asyncio +from seleniumbase import sb_cdp +from seleniumbase import cdp_driver + +url = "https://seleniumbase.io/demo_page" +loop = asyncio.new_event_loop() +driver = cdp_driver.start_sync() +page = loop.run_until_complete(driver.get(url)) +sb = sb_cdp.CDPMethods(loop, page, driver) + +sb.press_keys("input", "Text") +sb.highlight("button") +sb.type("textarea", "Here are some words") +sb.click("button") +sb.set_value("input#mySlider", "100") +sb.click_visible_elements("input.checkBoxClassB") +sb.select_option_by_text("#mySelect", "Set to 75%") +sb.gui_hover_and_click("#myDropdown", "#dropOption2") +sb.gui_click_element("#checkBox1") +sb.gui_drag_and_drop("img#logo", "div#drop2") +sb.nested_click("iframe#myFrame3", ".fBox") +sb.sleep(2) diff --git a/examples/cdp_mode/raw_cdp_methods.py b/examples/cdp_mode/raw_cdp_methods.py index de69f956..4d5c0cdf 100644 --- a/examples/cdp_mode/raw_cdp_methods.py +++ b/examples/cdp_mode/raw_cdp_methods.py @@ -1,13 +1,7 @@ -import asyncio -from seleniumbase.core import sb_cdp -from seleniumbase.undetected import cdp_driver +from seleniumbase import sb_cdp url = "https://seleniumbase.io/demo_page" -loop = asyncio.new_event_loop() -driver = cdp_driver.cdp_util.start_sync() -page = loop.run_until_complete(driver.get(url)) -sb = sb_cdp.CDPMethods(loop, page, driver) - +sb = sb_cdp.Chrome(url) sb.press_keys("input", "Text") sb.highlight("button") sb.type("textarea", "Here are some words") diff --git a/examples/cdp_mode/raw_cdp_nike.py b/examples/cdp_mode/raw_cdp_nike.py index 88c72539..e2b16298 100644 --- a/examples/cdp_mode/raw_cdp_nike.py +++ b/examples/cdp_mode/raw_cdp_nike.py @@ -1,19 +1,12 @@ -import asyncio -from seleniumbase.core import sb_cdp -from seleniumbase.undetected import cdp_driver +from seleniumbase import sb_cdp url = "https://www.nike.com/" -loop = asyncio.new_event_loop() -driver = cdp_driver.cdp_util.start_sync() -page = loop.run_until_complete(driver.get(url)) -sb = sb_cdp.CDPMethods(loop, page, driver) - -search = "Road Racing Shoes" +sb = sb_cdp.Chrome(url) sb.click('div[data-testid="user-tools-container"]') sb.sleep(1) +search = "Road Racing Shoes" sb.press_keys('input[type="search"]', search) sb.sleep(4) - elements = sb.select_all('ul[data-testid*="products"] figure .details') if elements: print('**** Found results for "%s": ****' % search) diff --git a/examples/cdp_mode/raw_cdp_with_sb.py b/examples/cdp_mode/raw_cdp_with_sb.py index 14ce948d..d2f911f4 100644 --- a/examples/cdp_mode/raw_cdp_with_sb.py +++ b/examples/cdp_mode/raw_cdp_with_sb.py @@ -2,7 +2,7 @@ from seleniumbase import SB -with SB(uc=True, test=True, locale_code="en") as sb: +with SB(uc=True, test=True, locale="en") as sb: url = "https://www.priceline.com/" sb.activate_cdp_mode(url) sb.sleep(2.5) diff --git a/examples/cdp_mode/raw_cf.py b/examples/cdp_mode/raw_cf.py index af11c133..1d91373d 100644 --- a/examples/cdp_mode/raw_cf.py +++ b/examples/cdp_mode/raw_cf.py @@ -1,14 +1,14 @@ """Using CDP Mode with PyAutoGUI to bypass CAPTCHAs.""" from seleniumbase import SB -with SB(uc=True, test=True, locale_code="en", guest=True) 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) sb.uc_gui_handle_captcha() # PyAutoGUI press Tab and Spacebar sb.sleep(2) -with SB(uc=True, test=True, locale_code="en", guest=True) 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) diff --git a/examples/cdp_mode/raw_easyjet.py b/examples/cdp_mode/raw_easyjet.py index 599277ff..32c73810 100644 --- a/examples/cdp_mode/raw_easyjet.py +++ b/examples/cdp_mode/raw_easyjet.py @@ -1,6 +1,6 @@ from seleniumbase import SB -with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb: +with SB(uc=True, test=True, locale="en", ad_block=True) as sb: url = "https://www.easyjet.com/en/" sb.activate_cdp_mode(url) sb.sleep(2.5) diff --git a/examples/cdp_mode/raw_elal.py b/examples/cdp_mode/raw_elal.py index 110b1e2b..81fe30cf 100644 --- a/examples/cdp_mode/raw_elal.py +++ b/examples/cdp_mode/raw_elal.py @@ -1,6 +1,6 @@ from seleniumbase import SB -with SB(uc=True, test=True, locale_code="en") as sb: +with SB(uc=True, test=True, locale="en") as sb: url = "www.elal.com/flight-deals/en-us/flights-from-boston-to-tel-aviv" sb.activate_cdp_mode(url) sb.sleep(2) @@ -36,19 +36,21 @@ with SB(uc=True, test=True, locale_code="en") as sb: sb.cdp.click(search_cell) sb.sleep(5) else: - elements = sb.cdp.find_elements("div.ui-bound__price__value") print("*** Lowest Prices: ***") - first = True + departure_prices = "#uiFlightPanel0 div.ui-bound__price__value" + return_prices = "#uiFlightPanel1 div.ui-bound__price__value" + elements = sb.cdp.find_elements(departure_prices) for element in elements: if "lowest price" in element.text: - if first: - print("Departure Flight:") - print(element.text) - first = False - else: - print("Return Flight:") - print(element.text) - break + print("Departure Flight:") + print(element.text) + break + elements = sb.cdp.find_elements(return_prices) + for element in elements: + if "lowest price" in element.text: + print("Return Flight:") + print(element.text) + break dates = sb.cdp.find_elements('div[class*="flight-date"]') if len(dates) == 2: print("*** Departure Date: ***") diff --git a/examples/cdp_mode/raw_footlocker.py b/examples/cdp_mode/raw_footlocker.py index 311d9148..cd2672fd 100644 --- a/examples/cdp_mode/raw_footlocker.py +++ b/examples/cdp_mode/raw_footlocker.py @@ -1,6 +1,6 @@ from seleniumbase import SB -with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb: +with SB(uc=True, test=True, locale="en", ad_block=True) as sb: url = "https://www.footlocker.com/" sb.activate_cdp_mode(url) sb.sleep(2.5) diff --git a/examples/cdp_mode/raw_gettyimages.py b/examples/cdp_mode/raw_gettyimages.py index d2cf0a4f..875a1707 100644 --- a/examples/cdp_mode/raw_gettyimages.py +++ b/examples/cdp_mode/raw_gettyimages.py @@ -1,6 +1,6 @@ from seleniumbase import SB -with SB(uc=True, test=True, locale_code="en", pls="none") as sb: +with SB(uc=True, test=True, locale="en", pls="none") as sb: sb.activate_cdp_mode("https://www.gettyimages.com/") sb.cdp.click('label:contains("Editorial")') sb.cdp.press_keys("form input", "comic con 2024 sci fi panel\n") diff --git a/examples/cdp_mode/raw_gitlab.py b/examples/cdp_mode/raw_gitlab.py index 870c1f68..e13a4c44 100644 --- a/examples/cdp_mode/raw_gitlab.py +++ b/examples/cdp_mode/raw_gitlab.py @@ -1,6 +1,6 @@ from seleniumbase import SB -with SB(uc=True, test=True, locale_code="en") 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.uc_gui_click_captcha() diff --git a/examples/cdp_mode/raw_hyatt.py b/examples/cdp_mode/raw_hyatt.py index 5c92a222..12fc3945 100644 --- a/examples/cdp_mode/raw_hyatt.py +++ b/examples/cdp_mode/raw_hyatt.py @@ -1,6 +1,6 @@ from seleniumbase import SB -with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb: +with SB(uc=True, test=True, locale="en", ad_block=True) as sb: url = "https://www.hyatt.com/" sb.activate_cdp_mode(url) sb.sleep(2.5) diff --git a/examples/cdp_mode/raw_kohls.py b/examples/cdp_mode/raw_kohls.py index a29fa7ca..e6e1da0a 100644 --- a/examples/cdp_mode/raw_kohls.py +++ b/examples/cdp_mode/raw_kohls.py @@ -1,6 +1,6 @@ from seleniumbase import SB -with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb: +with SB(uc=True, test=True, locale="en", ad_block=True) as sb: url = "https://www.kohls.com/" sb.activate_cdp_mode(url) sb.sleep(2.5) diff --git a/examples/cdp_mode/raw_multi_async.py b/examples/cdp_mode/raw_multi_async.py index cfbd64a2..afaf3238 100644 --- a/examples/cdp_mode/raw_multi_async.py +++ b/examples/cdp_mode/raw_multi_async.py @@ -2,11 +2,11 @@ import asyncio from concurrent.futures import ThreadPoolExecutor from random import randint -from seleniumbase.undetected import cdp_driver +from seleniumbase import cdp_driver async def main(url): - driver = await cdp_driver.cdp_util.start_async() + driver = await cdp_driver.start_async() page = await driver.get(url) await page.set_window_rect(randint(4, 600), randint(8, 410), 860, 500) await page.sleep(0.5) diff --git a/examples/cdp_mode/raw_multi_cdp.py b/examples/cdp_mode/raw_multi_cdp.py index c7f42f4f..b814b44c 100644 --- a/examples/cdp_mode/raw_multi_cdp.py +++ b/examples/cdp_mode/raw_multi_cdp.py @@ -1,16 +1,11 @@ # Testing multiple CDP drivers using the sync API -import asyncio from concurrent.futures import ThreadPoolExecutor from random import randint -from seleniumbase.core import sb_cdp -from seleniumbase.undetected import cdp_driver +from seleniumbase import sb_cdp def main(url): - loop = asyncio.new_event_loop() - driver = cdp_driver.cdp_util.start_sync() - page = loop.run_until_complete(driver.get(url)) - sb = sb_cdp.CDPMethods(loop, page, driver) + sb = sb_cdp.Chrome(url) sb.set_window_rect(randint(4, 720), randint(8, 410), 800, 500) sb.press_keys("input", "Text") sb.highlight("button") diff --git a/examples/cdp_mode/raw_nike.py b/examples/cdp_mode/raw_nike.py index 009f723d..7e28e2fc 100644 --- a/examples/cdp_mode/raw_nike.py +++ b/examples/cdp_mode/raw_nike.py @@ -1,10 +1,10 @@ from seleniumbase import SB -with SB(uc=True, test=True, locale_code="en", pls="none") as sb: +with SB(uc=True, test=True, locale="en", pls="none") as sb: url = "https://www.nike.com/" sb.activate_cdp_mode(url) sb.sleep(2.5) - sb.cdp.mouse_click('div[data-testid="user-tools-container"]') + sb.cdp.click('div[data-testid="user-tools-container"]') sb.sleep(1.5) search = "Nike Air Force 1" sb.cdp.press_keys('input[type="search"]', search) diff --git a/examples/cdp_mode/raw_nordstrom.py b/examples/cdp_mode/raw_nordstrom.py index f2f0f3e6..ddc34dd1 100644 --- a/examples/cdp_mode/raw_nordstrom.py +++ b/examples/cdp_mode/raw_nordstrom.py @@ -1,6 +1,6 @@ from seleniumbase import SB -with SB(uc=True, test=True, locale_code="en") as sb: +with SB(uc=True, test=True, locale="en") as sb: url = "https://www.nordstrom.com/" sb.activate_cdp_mode(url) sb.sleep(2.2) diff --git a/examples/cdp_mode/raw_pokemon.py b/examples/cdp_mode/raw_pokemon.py index 4aecd0c1..f52d2f97 100644 --- a/examples/cdp_mode/raw_pokemon.py +++ b/examples/cdp_mode/raw_pokemon.py @@ -1,6 +1,6 @@ from seleniumbase import SB -with SB(uc=True, test=True, locale_code="en", ad_block=True) as 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) diff --git a/examples/cdp_mode/raw_priceline.py b/examples/cdp_mode/raw_priceline.py index bac86601..6142f9f0 100644 --- a/examples/cdp_mode/raw_priceline.py +++ b/examples/cdp_mode/raw_priceline.py @@ -1,6 +1,6 @@ from seleniumbase import SB -with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb: +with SB(uc=True, test=True, locale="en", ad_block=True) as sb: window_handle = sb.driver.current_window_handle url = "https://www.priceline.com" sb.activate_cdp_mode(url) diff --git a/examples/cdp_mode/raw_publication.py b/examples/cdp_mode/raw_publication.py index 77c8b546..a3d5fd73 100644 --- a/examples/cdp_mode/raw_publication.py +++ b/examples/cdp_mode/raw_publication.py @@ -1,6 +1,6 @@ from seleniumbase import SB -with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb: +with SB(uc=True, test=True, locale="en", ad_block=True) as sb: url = "https://www.researchgate.net/search/publication" sb.activate_cdp_mode(url) sb.sleep(2) diff --git a/examples/cdp_mode/raw_radwell.py b/examples/cdp_mode/raw_radwell.py index 34a674ce..305b21cf 100644 --- a/examples/cdp_mode/raw_radwell.py +++ b/examples/cdp_mode/raw_radwell.py @@ -1,6 +1,6 @@ from seleniumbase import SB -with SB(uc=True, test=True, locale_code="en", incognito=True) as sb: +with SB(uc=True, test=True, locale="en", incognito=True) as sb: url = "https://www.radwell.com/en-US/Search/Advanced/" sb.activate_cdp_mode(url) sb.sleep(3) diff --git a/examples/cdp_mode/raw_req_async.py b/examples/cdp_mode/raw_req_async.py index 7101ce6c..663c93d4 100644 --- a/examples/cdp_mode/raw_req_async.py +++ b/examples/cdp_mode/raw_req_async.py @@ -4,7 +4,7 @@ import colorama import mycdp import sys from seleniumbase import decorators -from seleniumbase.undetected import cdp_driver +from seleniumbase import cdp_driver c1 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX c2 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX @@ -30,7 +30,7 @@ class RequestPausedTest(): ) async def start_test(self): - driver = await cdp_driver.cdp_util.start_async() + driver = await cdp_driver.start_async() tab = await driver.get("about:blank") tab.add_handler(mycdp.fetch.RequestPaused, self.request_paused_handler) url = "https://gettyimages.com/photos/firefly-2003-nathan" diff --git a/examples/cdp_mode/raw_req_mod.py b/examples/cdp_mode/raw_req_mod.py index eaa5f8d1..1609f1e0 100644 --- a/examples/cdp_mode/raw_req_mod.py +++ b/examples/cdp_mode/raw_req_mod.py @@ -14,7 +14,7 @@ async def request_paused_handler(event, tab): tab.feed_cdp(mycdp.fetch.continue_request(request_id=rid, url=new_url)) -with SB(uc=True, test=True, locale_code="en", pls="none") as sb: +with SB(uc=True, test=True, locale="en", pls="none") as sb: sb.activate_cdp_mode("about:blank") sb.cdp.add_handler(mycdp.fetch.RequestPaused, request_paused_handler) sb.cdp.open("https://gettyimages.com/photos/jonathan-frakes-cast-2022") diff --git a/examples/cdp_mode/raw_req_sb.py b/examples/cdp_mode/raw_req_sb.py index a547ab7a..96867257 100644 --- a/examples/cdp_mode/raw_req_sb.py +++ b/examples/cdp_mode/raw_req_sb.py @@ -23,7 +23,7 @@ async def request_paused_handler(event, tab): tab.feed_cdp(mycdp.fetch.fail_request(event.request_id, TIMED_OUT)) -with SB(uc=True, test=True, locale_code="en") as sb: +with SB(uc=True, test=True, locale="en") as sb: sb.activate_cdp_mode("about:blank") sb.cdp.add_handler(mycdp.fetch.RequestPaused, request_paused_handler) url = "https://gettyimages.com/photos/firefly-2003-nathan" diff --git a/examples/cdp_mode/raw_res_nike.py b/examples/cdp_mode/raw_res_nike.py index 459b143e..f4000c0e 100644 --- a/examples/cdp_mode/raw_res_nike.py +++ b/examples/cdp_mode/raw_res_nike.py @@ -25,13 +25,13 @@ async def receive_handler(event: mycdp.network.ResponseReceived): print(event.response) -with SB(uc=True, test=True, locale_code="en", pls="none") as sb: +with SB(uc=True, test=True, locale="en", pls="none") as sb: url = "https://www.nike.com/" sb.activate_cdp_mode(url) sb.cdp.add_handler(mycdp.network.RequestWillBeSent, send_handler) sb.cdp.add_handler(mycdp.network.ResponseReceived, receive_handler) sb.sleep(2.5) - sb.cdp.mouse_click('div[data-testid="user-tools-container"]') + sb.cdp.click('div[data-testid="user-tools-container"]') sb.sleep(1.5) search = "Nike Air Force 1" sb.cdp.press_keys('input[type="search"]', search) diff --git a/examples/cdp_mode/raw_res_sb.py b/examples/cdp_mode/raw_res_sb.py index 1534ec20..7ea86cd0 100644 --- a/examples/cdp_mode/raw_res_sb.py +++ b/examples/cdp_mode/raw_res_sb.py @@ -25,7 +25,7 @@ async def receive_handler(event: mycdp.network.ResponseReceived): print(event.response) -with SB(uc=True, test=True, locale_code="en") as sb: +with SB(uc=True, test=True, locale="en") as sb: sb.activate_cdp_mode("about:blank") sb.cdp.add_handler(mycdp.network.RequestWillBeSent, send_handler) sb.cdp.add_handler(mycdp.network.ResponseReceived, receive_handler) diff --git a/examples/cdp_mode/raw_southwest.py b/examples/cdp_mode/raw_southwest.py index 0253b747..1f9fcc0a 100644 --- a/examples/cdp_mode/raw_southwest.py +++ b/examples/cdp_mode/raw_southwest.py @@ -1,6 +1,6 @@ from seleniumbase import SB -with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb: +with SB(uc=True, test=True, locale="en", ad_block=True) as sb: url = "https://www.southwest.com/air/booking/" sb.activate_cdp_mode(url) sb.sleep(2.8) diff --git a/examples/cdp_mode/raw_theaters.py b/examples/cdp_mode/raw_theaters.py index 442c9454..2481ed3f 100644 --- a/examples/cdp_mode/raw_theaters.py +++ b/examples/cdp_mode/raw_theaters.py @@ -1,7 +1,7 @@ """Simple web-scraping example in CDP Mode""" from seleniumbase import SB -with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb: +with SB(uc=True, test=True, locale="en", ad_block=True) as sb: url = "https://architectureofcities.com/roman-theaters" sb.activate_cdp_mode(url) sb.cdp.click_if_visible("#cn-close-notice") diff --git a/examples/cdp_mode/raw_united.py b/examples/cdp_mode/raw_united.py index e819180c..cf39c8b1 100644 --- a/examples/cdp_mode/raw_united.py +++ b/examples/cdp_mode/raw_united.py @@ -1,6 +1,6 @@ from seleniumbase import SB -with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb: +with SB(uc=True, test=True, locale="en", ad_block=True) as sb: url = "https://www.united.com/en/us" sb.activate_cdp_mode(url) sb.sleep(2.5) diff --git a/examples/cdp_mode/raw_wsform.py b/examples/cdp_mode/raw_wsform.py index faee7c35..60586785 100644 --- a/examples/cdp_mode/raw_wsform.py +++ b/examples/cdp_mode/raw_wsform.py @@ -1,6 +1,6 @@ from seleniumbase import SB -with SB(uc=True, test=True, locale_code="en", incognito=True) as sb: +with SB(uc=True, test=True, locale="en", incognito=True) as sb: url = "https://wsform.com/demo/" sb.activate_cdp_mode(url) sb.scroll_into_view("div.grid") diff --git a/examples/cdp_mode/raw_xhr_async.py b/examples/cdp_mode/raw_xhr_async.py index 6f2f3c6e..ee548503 100644 --- a/examples/cdp_mode/raw_xhr_async.py +++ b/examples/cdp_mode/raw_xhr_async.py @@ -5,7 +5,7 @@ import colorama import mycdp import sys import time -from seleniumbase.undetected import cdp_driver +from seleniumbase import cdp_driver xhr_requests = [] last_xhr_request = None @@ -58,7 +58,7 @@ async def receiveXHR(page, requests): async def crawl(): - driver = await cdp_driver.cdp_util.start_async() + driver = await cdp_driver.start_async() tab = await driver.get("about:blank") listenXHR(tab) diff --git a/examples/cdp_mode/raw_xhr_sb.py b/examples/cdp_mode/raw_xhr_sb.py index 2475fe7f..81ff2782 100644 --- a/examples/cdp_mode/raw_xhr_sb.py +++ b/examples/cdp_mode/raw_xhr_sb.py @@ -56,7 +56,7 @@ async def receiveXHR(page, requests): return responses -with SB(uc=True, test=True, locale_code="en") as sb: +with SB(uc=True, test=True, locale="en") as sb: sb.activate_cdp_mode("about:blank") tab = sb.cdp.page listenXHR(tab) diff --git a/examples/presenter/uc_presentation_3.py b/examples/presenter/uc_presentation_3.py index 3f6d6ca2..99815938 100644 --- a/examples/presenter/uc_presentation_3.py +++ b/examples/presenter/uc_presentation_3.py @@ -273,7 +273,7 @@ class UCPresentationClass(BaseCase): self.begin_presentation(filename="uc_presentation.html") with suppress(Exception): - with SB(uc=True, incognito=True, locale_code="en") as sb: + with SB(uc=True, incognito=True, locale="en") as sb: url = "https://ahrefs.com/website-authority-checker" input_field = 'input[placeholder="Enter domain"]' submit_button = 'span:contains("Check Authority")' diff --git a/examples/presenter/uc_presentation_4.py b/examples/presenter/uc_presentation_4.py index 42ff12b3..4732f2e7 100644 --- a/examples/presenter/uc_presentation_4.py +++ b/examples/presenter/uc_presentation_4.py @@ -352,7 +352,7 @@ class UCPresentationClass(BaseCase): ) self.begin_presentation(filename="uc_presentation.html") - with SB(uc=True, test=True, locale_code="en") as sb: + with SB(uc=True, test=True, locale="en") as sb: url = "www.planetminecraft.com/account/sign_in/" sb.activate_cdp_mode(url) sb.sleep(2) @@ -367,7 +367,7 @@ class UCPresentationClass(BaseCase): ) self.begin_presentation(filename="uc_presentation.html") - with SB(uc=True, test=True, locale_code="en") as sb: + with SB(uc=True, test=True, locale="en") as sb: url = "https://www.cloudflare.com/login" sb.activate_cdp_mode(url) sb.sleep(3) @@ -382,7 +382,7 @@ class UCPresentationClass(BaseCase): ) self.begin_presentation(filename="uc_presentation.html") - with SB(uc=True, test=True, locale_code="en") 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) @@ -433,7 +433,7 @@ class UCPresentationClass(BaseCase): ) self.begin_presentation(filename="uc_presentation.html") - with SB(uc=True, test=True, locale_code="en") as sb: + with SB(uc=True, test=True, locale="en") as sb: url = "https://www.bing.com/turing/captcha/challenge" sb.activate_cdp_mode(url) sb.sleep(1) @@ -458,7 +458,7 @@ class UCPresentationClass(BaseCase): ) self.begin_presentation(filename="uc_presentation.html") - with SB(uc=True, test=True, locale_code="en", ad_block=True) as 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) @@ -565,7 +565,7 @@ class UCPresentationClass(BaseCase): ) self.begin_presentation(filename="uc_presentation.html") - with SB(uc=True, test=True, locale_code="en") as sb: + with SB(uc=True, test=True, locale="en") as sb: url = "https://www.albertsons.com/recipes/" sb.activate_cdp_mode(url) sb.sleep(2.5) @@ -611,7 +611,7 @@ class UCPresentationClass(BaseCase): ) self.begin_presentation(filename="uc_presentation.html") - with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb: + with SB(uc=True, test=True, locale="en", ad_block=True) as sb: url = "https://www.easyjet.com/en/" sb.activate_cdp_mode(url) sb.sleep(2.5) @@ -678,7 +678,7 @@ class UCPresentationClass(BaseCase): ) self.begin_presentation(filename="uc_presentation.html") - with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb: + with SB(uc=True, test=True, locale="en", ad_block=True) as sb: url = "https://www.hyatt.com/" sb.activate_cdp_mode(url) sb.sleep(2.5) @@ -727,7 +727,7 @@ class UCPresentationClass(BaseCase): ) self.begin_presentation(filename="uc_presentation.html") - with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb: + with SB(uc=True, test=True, locale="en", ad_block=True) as sb: url = "https://www.bestwestern.com/en_US.html" sb.activate_cdp_mode(url) sb.sleep(2.5) @@ -769,7 +769,7 @@ class UCPresentationClass(BaseCase): ) self.begin_presentation(filename="uc_presentation.html") - with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb: + with SB(uc=True, test=True, locale="en", ad_block=True) as sb: window_handle = sb.driver.current_window_handle url = "https://www.priceline.com" sb.activate_cdp_mode(url) @@ -838,11 +838,11 @@ class UCPresentationClass(BaseCase): ) self.begin_presentation(filename="uc_presentation.html") - with SB(uc=True, test=True, locale_code="en", pls="none") as sb: + with SB(uc=True, test=True, locale="en", pls="none") as sb: url = "https://www.nike.com/" sb.activate_cdp_mode(url) sb.sleep(2.5) - sb.cdp.mouse_click('div[data-testid="user-tools-container"]') + sb.cdp.click('div[data-testid="user-tools-container"]') sb.sleep(1.5) search = "Nike Air Force 1" sb.cdp.press_keys('input[type="search"]', search) @@ -866,7 +866,7 @@ class UCPresentationClass(BaseCase): ) self.begin_presentation(filename="uc_presentation.html") - with SB(uc=True, test=True, locale_code="en") as sb: + with SB(uc=True, test=True, locale="en") as sb: url = "https://www.nordstrom.com/" sb.activate_cdp_mode(url) sb.sleep(2.2) diff --git a/examples/raw_ahrefs.py b/examples/raw_ahrefs.py index 3c8441cd..2849374c 100644 --- a/examples/raw_ahrefs.py +++ b/examples/raw_ahrefs.py @@ -1,12 +1,11 @@ from seleniumbase import SB -with SB(uc=True, test=True, incognito=True, locale_code="en") as sb: +with SB(uc=True, test=True, incognito=True, locale="en") as sb: url = "https://ahrefs.com/website-authority-checker" input_field = 'input[placeholder="Enter domain"]' submit_button = 'span:contains("Check Authority")' sb.uc_open_with_reconnect(url) # The bot-check is later sb.type(input_field, "github.com/seleniumbase/SeleniumBase") - sb.reconnect(0.1) sb.uc_click(submit_button, reconnect_time=3.25) sb.uc_gui_click_captcha() sb.wait_for_text_not_visible("Checking", timeout=15) diff --git a/examples/raw_cf.py b/examples/raw_cf.py index 58df9df8..e6152bc1 100644 --- a/examples/raw_cf.py +++ b/examples/raw_cf.py @@ -1,13 +1,13 @@ """SB Manager using UC Mode & PyAutoGUI for bypassing CAPTCHAs.""" from seleniumbase import SB -with SB(uc=True, test=True, locale_code="en") as sb: +with SB(uc=True, test=True, locale="en") as sb: url = "https://www.cloudflare.com/login" sb.uc_open_with_reconnect(url, 5.5) sb.uc_gui_handle_captcha() # PyAutoGUI press Tab and Spacebar sb.sleep(2.5) -with SB(uc=True, test=True, locale_code="en") as sb: +with SB(uc=True, test=True, locale="en") as sb: url = "https://www.cloudflare.com/login" sb.uc_open_with_reconnect(url, 5.5) sb.uc_gui_click_captcha() # PyAutoGUI click. (Linux needs it) diff --git a/help_docs/syntax_formats.md b/help_docs/syntax_formats.md index c3ab0f25..7ea94c35 100644 --- a/help_docs/syntax_formats.md +++ b/help_docs/syntax_formats.md @@ -33,7 +33,7 @@
  • 22. The driver manager (via context manager)
  • 23. The driver manager (via direct import)
  • 24. CDP driver (async/await API. No Selenium)
  • -
  • 25. CDP driver (SB-CDP sync API. No Selenium)
  • +
  • 25. CDP driver (SB CDP Sync API. No Selenium)
  • @@ -1019,14 +1019,13 @@ This format provides a pure CDP way of using SeleniumBase (without Selenium or a ```python import asyncio import time -from seleniumbase.undetected import cdp_driver +from seleniumbase import cdp_driver async def main(): - driver = await cdp_driver.cdp_util.start_async() - page = await driver.get("about:blank") - await page.set_locale("en") - await page.get("https://www.priceline.com/") + url = "https://www.priceline.com/" + driver = await cdp_driver.start_async(lang="en") + page = await driver.get(url) time.sleep(3) print(await page.evaluate("document.title")) element = await page.select('[data-testid*="endLocation"]') @@ -1043,25 +1042,17 @@ if __name__ == "__main__": (See examples/cdp_mode/raw_async.py for the test.) -

    25. CDP driver (SB-CDP sync API. No Selenium)

    +

    25. CDP driver (SB CDP Sync API. No Selenium)

    -This format provides a pure CDP way of using SeleniumBase (without Selenium or a test runner). The expanded SB-CDP sync API is used. Here's an example: +This format provides a pure CDP way of using SeleniumBase (without Selenium or a test runner). The expanded SB CDP Sync API is used. Here's an example: ```python -import asyncio -from seleniumbase.core import sb_cdp -from seleniumbase.undetected import cdp_driver +from seleniumbase import sb_cdp def main(): - url0 = "about:blank" # Set Locale code from here first - url1 = "https://www.priceline.com/" # (The "real" URL) - loop = asyncio.new_event_loop() - driver = cdp_driver.cdp_util.start_sync() - page = loop.run_until_complete(driver.get(url0)) - sb = sb_cdp.CDPMethods(loop, page, driver) - sb.set_locale("en") # This test expects English locale - sb.open(url1) + url = "https://www.priceline.com/" + sb = sb_cdp.Chrome(url, lang="en") sb.sleep(2.5) sb.internalize_links() # Don't open links in a new tab sb.click("#link_header_nav_experiences") diff --git a/help_docs/uc_mode.md b/help_docs/uc_mode.md index ef9d37f7..569c73c1 100644 --- a/help_docs/uc_mode.md +++ b/help_docs/uc_mode.md @@ -104,7 +104,7 @@ Sometimes you need to add incognito=True with + +Then you can run these commands: + + export DOCKER_DEFAULT_PLATFORM=linux/amd64 docker build --platform linux/amd64 -t seleniumbase . -**M1/M2 Mac users** should also see [StackOverflow.com/a/76586216/7058266](https://stackoverflow.com/a/76586216/7058266) to **Enable Rosetta in Docker Desktop**. (Otherwise **you will** encounter errors like this when Chrome tries to launch: `"Chrome failed to start: crashed."`) - #### 4. Run [the example test](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py) with Chrome inside your Docker: (Once the test completes after a few seconds, you'll automatically exit the Docker shell) docker run seleniumbase ./run_docker_test_in_chrome.sh diff --git a/requirements.txt b/requirements.txt index 1a0f763c..bd46959f 100755 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ pip>=25.0.1 packaging>=24.2 setuptools~=70.2;python_version<"3.10" -setuptools>=75.8.0;python_version>="3.10" +setuptools>=75.8.2;python_version>="3.10" wheel>=0.45.1 attrs>=25.1.0 certifi>=2025.1.31 @@ -39,7 +39,7 @@ h11==0.14.0 outcome==1.3.0.post0 trio==0.27.0;python_version<"3.9" trio==0.29.0;python_version>="3.9" -trio-websocket==0.12.1 +trio-websocket==0.12.2 wsproto==1.2.0 websocket-client==1.8.0 selenium==4.27.1;python_version<"3.9" diff --git a/seleniumbase/__init__.py b/seleniumbase/__init__.py index 59f564c3..de258d40 100644 --- a/seleniumbase/__init__.py +++ b/seleniumbase/__init__.py @@ -8,6 +8,7 @@ from seleniumbase.__version__ import __version__ from seleniumbase.common import decorators # noqa from seleniumbase.common import encryption # noqa from seleniumbase.core import colored_traceback +from seleniumbase.core import sb_cdp # noqa from seleniumbase.core.browser_launcher import get_driver # noqa from seleniumbase.fixtures import js_utils # noqa from seleniumbase.fixtures import page_actions # noqa @@ -18,6 +19,7 @@ from seleniumbase.masterqa.master_qa import MasterQA # noqa from seleniumbase.plugins.sb_manager import SB # noqa from seleniumbase.plugins.driver_manager import Driver # noqa from seleniumbase.plugins.driver_manager import DriverContext # noqa +from seleniumbase.undetected import cdp_driver # noqa from seleniumbase import translate # noqa with suppress(Exception): diff --git a/seleniumbase/__version__.py b/seleniumbase/__version__.py index 9cf6d36f..95801f55 100755 --- a/seleniumbase/__version__.py +++ b/seleniumbase/__version__.py @@ -1,2 +1,2 @@ # seleniumbase package -__version__ = "4.35.1" +__version__ = "4.35.2" diff --git a/seleniumbase/core/browser_launcher.py b/seleniumbase/core/browser_launcher.py index 79fb720f..8d6e9956 100644 --- a/seleniumbase/core/browser_launcher.py +++ b/seleniumbase/core/browser_launcher.py @@ -235,8 +235,12 @@ def extend_driver(driver, proxy_auth=False, use_uc=True): driver.reset_window_size = DM.reset_window_size if hasattr(driver, "proxy"): driver.set_wire_proxy = DM.set_wire_proxy - if proxy_auth and not use_uc: - time.sleep(0.11) # Proxy needs moment to load in Manifest V3 + if proxy_auth: + # Proxy needs a moment to load in Manifest V3 + if use_uc: + time.sleep(0.12) + else: + time.sleep(0.22) return driver diff --git a/seleniumbase/core/sb_cdp.py b/seleniumbase/core/sb_cdp.py index c5c4a3fa..e0b6c634 100644 --- a/seleniumbase/core/sb_cdp.py +++ b/seleniumbase/core/sb_cdp.py @@ -1,4 +1,5 @@ """Add CDP methods to extend the driver""" +import asyncio import fasteners import os import re @@ -11,6 +12,7 @@ from seleniumbase.fixtures import constants from seleniumbase.fixtures import js_utils from seleniumbase.fixtures import page_utils from seleniumbase.fixtures import shared_utils +from seleniumbase.undetected.cdp_driver import cdp_util class CDPMethods(): @@ -208,14 +210,16 @@ class CDPMethods(): element = self.__add_sync_methods(element) return self.__add_sync_methods(element) elif ( - element.parent + element + and element.parent and tag_name in element.parent.tag_name.lower() and text.strip() in element.parent.text ): element = self.__add_sync_methods(element.parent) return self.__add_sync_methods(element) elif ( - element.parent + element + and element.parent and element.parent.parent and tag_name in element.parent.parent.tag_name.lower() and text.strip() in element.parent.parent.text @@ -269,7 +273,8 @@ class CDPMethods(): if element not in updated_elements: updated_elements.append(element) elif ( - element.parent + element + and element.parent and tag_name in element.parent.tag_name.lower() and text.strip() in element.parent.text ): @@ -277,7 +282,8 @@ class CDPMethods(): if element not in updated_elements: updated_elements.append(element) elif ( - element.parent + element + and element.parent and element.parent.parent and tag_name in element.parent.parent.tag_name.lower() and text.strip() in element.parent.parent.text @@ -2093,3 +2099,13 @@ class CDPMethods(): ) else: self.select(selector).save_screenshot(filename) + + +class Chrome(CDPMethods): + def __init__(self, url=None, **kwargs): + if not url: + url = "about:blank" + loop = asyncio.new_event_loop() + driver = cdp_util.start_sync(**kwargs) + page = loop.run_until_complete(driver.get(url)) + super().__init__(loop, page, driver) diff --git a/seleniumbase/undetected/cdp_driver/__init__.py b/seleniumbase/undetected/cdp_driver/__init__.py index 8cc0fcf4..a2c67f3d 100644 --- a/seleniumbase/undetected/cdp_driver/__init__.py +++ b/seleniumbase/undetected/cdp_driver/__init__.py @@ -1 +1,3 @@ from seleniumbase.undetected.cdp_driver import cdp_util # noqa +from seleniumbase.undetected.cdp_driver.cdp_util import start_async # noqa +from seleniumbase.undetected.cdp_driver.cdp_util import start_sync # noqa diff --git a/seleniumbase/undetected/cdp_driver/browser.py b/seleniumbase/undetected/cdp_driver/browser.py index 04c2de21..638ef8e0 100644 --- a/seleniumbase/undetected/cdp_driver/browser.py +++ b/seleniumbase/undetected/cdp_driver/browser.py @@ -15,6 +15,7 @@ import urllib.parse import urllib.request import warnings from collections import defaultdict +from seleniumbase import config as sb_config from typing import List, Set, Tuple, Union import mycdp as cdp from . import cdp_util as util @@ -287,6 +288,9 @@ class Browser: filter(lambda item: item.type_ == "page", self.targets) ) # Use the tab to navigate to new url + if hasattr(sb_config, "_cdp_locale") and sb_config._cdp_locale: + await connection.send(cdp.page.navigate("about:blank")) + await connection.set_locale(sb_config._cdp_locale) frame_id, loader_id, *_ = await connection.send( cdp.page.navigate(url) ) diff --git a/seleniumbase/undetected/cdp_driver/cdp_util.py b/seleniumbase/undetected/cdp_driver/cdp_util.py index a39f0c5d..ab5886b6 100644 --- a/seleniumbase/undetected/cdp_driver/cdp_util.py +++ b/seleniumbase/undetected/cdp_driver/cdp_util.py @@ -232,9 +232,9 @@ async def start( browser_args: Optional[List[str]] = None, xvfb_metrics: Optional[List[str]] = None, # "Width,Height" for Linux sandbox: Optional[bool] = True, - lang: Optional[str] = None, - host: Optional[str] = None, - port: Optional[int] = None, + lang: Optional[str] = None, # Set the Language Locale Code + host: Optional[str] = None, # Chrome remote-debugging-host + port: Optional[int] = None, # Chrome remote-debugging-port xvfb: Optional[int] = None, # Use a special virtual display on Linux headed: Optional[bool] = None, # Override default Xvfb mode on Linux expert: Optional[bool] = None, # Open up closed Shadow-root elements @@ -320,7 +320,15 @@ async def start( time.sleep(0.15) driver = await Browser.create(config) if proxy and "@" in str(proxy): - time.sleep(0.11) + time.sleep(0.15) + if lang: + sb_config._cdp_locale = lang + elif "locale" in kwargs: + sb_config._cdp_locale = kwargs["locale"] + elif "locale_code" in kwargs: + sb_config._cdp_locale = kwargs["locale_code"] + else: + sb_config._cdp_locale = None return driver @@ -360,10 +368,7 @@ def start_sync(*args, **kwargs) -> Browser: ): loop = kwargs["loop"] else: - try: - loop = asyncio.get_event_loop() - except RuntimeError: - loop = asyncio.new_event_loop() + loop = asyncio.new_event_loop() headless = False binary_location = None if "browser_executable_path" in kwargs: diff --git a/setup.py b/setup.py index dbcf8eee..f2cea720 100755 --- a/setup.py +++ b/setup.py @@ -150,7 +150,7 @@ setup( 'pip>=25.0.1', 'packaging>=24.2', 'setuptools~=70.2;python_version<"3.10"', # Newer ones had issues - 'setuptools>=75.8.0;python_version>="3.10"', + 'setuptools>=75.8.2;python_version>="3.10"', 'wheel>=0.45.1', 'attrs>=25.1.0', "certifi>=2025.1.31", @@ -188,7 +188,7 @@ setup( 'outcome==1.3.0.post0', 'trio==0.27.0;python_version<"3.9"', 'trio==0.29.0;python_version>="3.9"', - 'trio-websocket==0.12.1', + 'trio-websocket==0.12.2', 'wsproto==1.2.0', 'websocket-client==1.8.0', 'selenium==4.27.1;python_version<"3.9"', @@ -283,7 +283,7 @@ setup( ], # pip install -e .[psutil] "psutil": [ - "psutil==6.0.0", + "psutil==7.0.0", ], # pip install -e .[pyautogui] "pyautogui": [