diff --git a/examples/cdp_mode/raw_easyjet.py b/examples/cdp_mode/raw_easyjet.py index 35ef468d171..d8128fd6402 100644 --- a/examples/cdp_mode/raw_easyjet.py +++ b/examples/cdp_mode/raw_easyjet.py @@ -26,7 +26,7 @@ sb.sleep(3.5) sb.connect() sb.sleep(0.5) - if "easyjet.com" not in sb.get_current_url(): + if "/buy/flights" not in sb.get_current_url(): sb.driver.close() sb.switch_to_newest_window() days = sb.find_elements("div.flight-grid-day") diff --git a/examples/cdp_mode/raw_hyatt.py b/examples/cdp_mode/raw_hyatt.py index 38d372ae890..ef17928e316 100644 --- a/examples/cdp_mode/raw_hyatt.py +++ b/examples/cdp_mode/raw_hyatt.py @@ -23,7 +23,7 @@ 'div[data-booking-status="BOOKABLE"] [class*="HotelCard_header"]' ) hotel_prices = sb.cdp.select_all( - 'div[data-booking-status="BOOKABLE"] div.rate-currency' + 'div[data-booking-status="BOOKABLE"] div.rate' ) sb.assert_true(len(hotel_names) == len(hotel_prices)) print("Hyatt Hotels in %s:" % location) diff --git a/examples/cdp_mode/raw_nike.py b/examples/cdp_mode/raw_nike.py new file mode 100644 index 00000000000..8521d263040 --- /dev/null +++ b/examples/cdp_mode/raw_nike.py @@ -0,0 +1,17 @@ +from seleniumbase import SB + +with SB(uc=True, test=True, locale_code="en") as sb: + url = "https://www.nike.com/" + sb.activate_cdp_mode(url) + sb.sleep(3) + sb.cdp.gui_click_element('div[data-testid="user-tools-container"]') + sb.sleep(1.5) + search = "Nike Air Force 1" + sb.cdp.press_keys('input[type="search"]', search) + sb.sleep(4) + elements = sb.cdp.select_all('ul[data-testid*="products"] figure .details') + if elements: + print('**** Found results for "%s": ****' % search) + for element in elements: + print("* " + element.text) + sb.sleep(2) diff --git a/examples/github_test.py b/examples/github_test.py index b5ba3b8f492..fe2d6dd4574 100644 --- a/examples/github_test.py +++ b/examples/github_test.py @@ -16,4 +16,4 @@ def test_github(self): self.assert_text("SeleniumBase", "strong a") self.js_click('a[title="seleniumbase"]') self.slow_click('td[class*="large"] a[title="fixtures"]') - self.assert_element('td[class*="large"] a[title="base_case.py"]') + self.highlight('td[class*="large"] a[title="base_case.py"]', loops=8) diff --git a/examples/hack_the_planet.py b/examples/hack_the_planet.py index 19466028cf9..1d5d3aa6b57 100644 --- a/examples/hack_the_planet.py +++ b/examples/hack_the_planet.py @@ -5,7 +5,7 @@ class HackTests(BaseCase): def test_all_your_base_are_belong_to_us(self): - self.set_window_size(1220, 740) + self.set_window_size(1250, 740) ayb = "ALL YOUR BASE" abtu = "ARE BELONG TO US" aybabtu = "%s %s" % (ayb, abtu) @@ -22,8 +22,7 @@ def test_all_your_base_are_belong_to_us(self): self.set_text_content("#n-currentevents a", "BASE") self.set_text_content("#n-randompage a", "ARE") self.set_text_content("#n-aboutsite a", "BELONG") - self.set_text_content("#n-contactpage a", "TO") - self.set_text_content("#n-sitesupport a", "US") + self.set_text_content("#n-contactpage a", "TO US") self.highlight("h1#firstHeading", loops=5, scroll=False) zoom_in = "#ca-history a{zoom: 1.8;-moz-transform: scale(1.8);}" self.add_css_style(zoom_in) @@ -86,11 +85,8 @@ def test_all_your_base_are_belong_to_us(self): self.highlight('form[role="search"]', loops=8) self.open("https://github.com/features/actions") - self.set_text_content("h2.h2-mktg", aybabtu) - self.set_text_content("a.btn-large-mktg", aybabtu) - self.highlight("h2.h2-mktg", loops=8, scroll=False) - self.scroll_to("h2.h2-mktg") - self.highlight("a.btn-large-mktg", loops=8, scroll=False) + self.set_text_content("#hero-section-brand-heading", aybabtu) + self.highlight("#hero-section-brand-heading", loops=14, scroll=False) self.open("https://dev.to/top/infinity") self.click_if_visible('button[aria-label="Close campaign banner"]') diff --git a/examples/raw_recaptcha.py b/examples/raw_recaptcha.py index 1073ea4309f..da37b648a9a 100644 --- a/examples/raw_recaptcha.py +++ b/examples/raw_recaptcha.py @@ -2,6 +2,7 @@ with SB(uc=True, test=True) as sb: url = "https://seleniumbase.io/apps/recaptcha" + sb.activate_cdp_mode(url) sb.uc_gui_handle_captcha() # Try with TAB + SPACEBAR sb.assert_element("img#captcha-success", timeout=3) sb.set_messenger_theme(location="top_left") @@ -9,6 +10,7 @@ with SB(uc=True, test=True) as sb: url = "https://seleniumbase.io/apps/recaptcha" + sb.activate_cdp_mode(url) sb.uc_gui_click_captcha('iframe[src*="/recaptcha/"]') sb.assert_element("img#captcha-success", timeout=3) sb.set_messenger_theme(location="top_left") diff --git a/requirements.txt b/requirements.txt index bc3ffee5f27..6773ca43f29 100755 --- a/requirements.txt +++ b/requirements.txt @@ -57,7 +57,7 @@ pyotp==2.9.0 python-xlib==0.33;platform_system=="Linux" markdown-it-py==3.0.0 mdurl==0.1.2 -rich==13.9.3 +rich==13.9.4 # --- Testing Requirements --- # # ("pip install -r requirements.txt" also installs this, but "pip install -e ." won't.) diff --git a/seleniumbase/__version__.py b/seleniumbase/__version__.py index 884e2a6ef40..bdf522609f0 100755 --- a/seleniumbase/__version__.py +++ b/seleniumbase/__version__.py @@ -1,2 +1,2 @@ # seleniumbase package -__version__ = "4.32.6" +__version__ = "4.32.7" diff --git a/seleniumbase/core/browser_launcher.py b/seleniumbase/core/browser_launcher.py index 1060016c7a0..14e34da36ec 100644 --- a/seleniumbase/core/browser_launcher.py +++ b/seleniumbase/core/browser_launcher.py @@ -2128,6 +2128,10 @@ def _set_chrome_options( binary_loc = detect_b_ver.get_binary_location(br_app, True) if os.path.exists(binary_loc): binary_location = binary_loc + elif os.path.exists("/usr/bin/google-chrome-stable"): + binary_location = "/usr/bin/google-chrome-stable" + elif os.path.exists("/usr/bin/google-chrome"): + binary_location = "/usr/bin/google-chrome" extra_disabled_features = [] if chromium_arg: # Can be a comma-separated list of Chromium args or a list @@ -2228,6 +2232,8 @@ def _set_chrome_options( chrome_options.add_argument("--wm-window-animations-disabled") chrome_options.add_argument("--enable-privacy-sandbox-ads-apis") chrome_options.add_argument("--disable-background-timer-throttling") + # Prevent new tabs opened by Selenium from being blocked: + chrome_options.add_argument("--disable-popup-blocking") # Skip remaining options that trigger anti-bot services return chrome_options chrome_options.add_argument("--test-type") diff --git a/setup.py b/setup.py index b26122db586..111de78a14e 100755 --- a/setup.py +++ b/setup.py @@ -206,7 +206,7 @@ 'python-xlib==0.33;platform_system=="Linux"', 'markdown-it-py==3.0.0', 'mdurl==0.1.2', - 'rich==13.9.3', + 'rich==13.9.4', ], extras_require={ # pip install -e .[allure]