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
32 changes: 17 additions & 15 deletions examples/cdp_mode/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,17 @@ from seleniumbase import 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)
sb.cdp.click_if_visible('button[aria-label="Close"]')
sb.cdp.click_if_visible("#onetrust-reject-all-handler")
sb.sleep(2)
sb.sleep(3.5)
sb.click_if_visible('button[aria-label="Close"]')
sb.click_if_visible("#onetrust-reject-all-handler")
sb.sleep(1)
location = "Anaheim, CA, USA"
sb.cdp.type('input[data-id="location"]', location)
sb.cdp.click("button.quickbookSearchFormButton")
sb.sleep(5)
sb.type('input[id="search-term"]', location)
sb.sleep(1)
sb.click('li[data-js="suggestion"]')
sb.sleep(1)
sb.click("button.be-button-shop")
sb.sleep(6)
card_info = 'div[data-booking-status="BOOKABLE"] [class*="HotelCard_info"]'
hotels = sb.cdp.select_all(card_info)
print("Hyatt Hotels in %s:" % location)
Expand Down Expand Up @@ -274,22 +277,21 @@ from seleniumbase import SB
with SB(uc=True, test=True, ad_block=True) as sb:
url = "https://www.walmart.com/"
sb.activate_cdp_mode(url)
sb.sleep(2.5)
sb.cdp.click_if_visible('[data-automation-id*="close-mark"]')
sb.sleep(0.3)
sb.cdp.mouse_click('input[aria-label="Search"]')
sb.sleep(2.8)
sb.click('input[aria-label="Search"]')
sb.sleep(1.2)
search = "Settlers of Catan Board Game"
required_text = "Catan"
sb.cdp.press_keys('input[aria-label="Search"]', search + "\n")
sb.press_keys('input[aria-label="Search"]', search + "\n")
sb.sleep(3.8)
if sb.is_element_visible("#px-captcha"):
sb.cdp.gui_click_and_hold("#px-captcha", 12)
sb.sleep(3.2)
sb.cdp.gui_click_and_hold("#px-captcha", 7.2)
sb.sleep(4.2)
if sb.is_element_visible("#px-captcha"):
sb.cdp.gui_click_and_hold("#px-captcha", 12)
sb.cdp.gui_click_and_hold("#px-captcha", 4.2)
sb.sleep(3.2)
sb.cdp.remove_elements('[data-testid="skyline-ad"]')
sb.cdp.remove_elements('[data-testid="sba-container"]')
print('*** Walmart Search for "%s":' % search)
print(' (Results must contain "%s".)' % required_text)
unique_item_text = []
Expand Down
2 changes: 1 addition & 1 deletion examples/cdp_mode/raw_consecutive_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
sb.activate_cdp_mode(url)
sb.sleep(2.2)
sb.uc_gui_click_captcha()
sb.sleep(2.2)
sb.sleep(2.6)
sb.uc_gui_click_captcha()
sb.sleep(2)
17 changes: 10 additions & 7 deletions examples/cdp_mode/raw_hyatt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
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)
sb.cdp.click_if_visible('button[aria-label="Close"]')
sb.cdp.click_if_visible("#onetrust-reject-all-handler")
sb.sleep(2)
sb.sleep(3.5)
sb.click_if_visible('button[aria-label="Close"]')
sb.click_if_visible("#onetrust-reject-all-handler")
sb.sleep(1)
location = "Anaheim, CA, USA"
sb.cdp.type('input[data-id="location"]', location)
sb.cdp.click("button.quickbookSearchFormButton")
sb.sleep(5)
sb.type('input[id="search-term"]', location)
sb.sleep(1)
sb.click('li[data-js="suggestion"]')
sb.sleep(1)
sb.click("button.be-button-shop")
sb.sleep(6)
card_info = 'div[data-booking-status="BOOKABLE"] [class*="HotelCard_info"]'
hotels = sb.cdp.select_all(card_info)
print("Hyatt Hotels in %s:" % location)
Expand Down
2 changes: 1 addition & 1 deletion examples/cdp_mode/raw_nordstrom.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
price = item.querySelector('div div span[aria-hidden="true"]')
if price:
price_text = price.text
print("* %s (%s)" % (description.text, price_text))
print("* %s (%s)" % (description.text, price_text))
15 changes: 7 additions & 8 deletions examples/cdp_mode/raw_walmart.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,21 @@
with SB(uc=True, test=True, ad_block=True) as sb:
url = "https://www.walmart.com/"
sb.activate_cdp_mode(url)
sb.sleep(2.5)
sb.cdp.click_if_visible('[data-automation-id*="close-mark"]')
sb.sleep(0.3)
sb.cdp.mouse_click('input[aria-label="Search"]')
sb.sleep(2.8)
sb.click('input[aria-label="Search"]')
sb.sleep(1.2)
search = "Settlers of Catan Board Game"
required_text = "Catan"
sb.cdp.press_keys('input[aria-label="Search"]', search + "\n")
sb.press_keys('input[aria-label="Search"]', search + "\n")
sb.sleep(3.8)
if sb.is_element_visible("#px-captcha"):
sb.cdp.gui_click_and_hold("#px-captcha", 12)
sb.sleep(3.2)
sb.cdp.gui_click_and_hold("#px-captcha", 7.2)
sb.sleep(4.2)
if sb.is_element_visible("#px-captcha"):
sb.cdp.gui_click_and_hold("#px-captcha", 12)
sb.cdp.gui_click_and_hold("#px-captcha", 4.2)
sb.sleep(3.2)
sb.cdp.remove_elements('[data-testid="skyline-ad"]')
sb.cdp.remove_elements('[data-testid="sba-container"]')
print('*** Walmart Search for "%s":' % search)
print(' (Results must contain "%s".)' % required_text)
unique_item_text = []
Expand Down
19 changes: 11 additions & 8 deletions examples/presenter/uc_presentation_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,14 +684,17 @@ def test_presentation_4(self):
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)
sb.cdp.click_if_visible('button[aria-label="Close"]')
sb.cdp.click_if_visible("#onetrust-reject-all-handler")
sb.sleep(2)
sb.sleep(3.5)
sb.click_if_visible('button[aria-label="Close"]')
sb.click_if_visible("#onetrust-reject-all-handler")
sb.sleep(1)
location = "Anaheim, CA, USA"
sb.cdp.type('input[data-id="location"]', location)
sb.cdp.click("button.quickbookSearchFormButton")
sb.sleep(5)
sb.type('input[id="search-term"]', location)
sb.sleep(1)
sb.click('li[data-js="suggestion"]')
sb.sleep(1)
sb.click("button.be-button-shop")
sb.sleep(6)
card_info = (
'div[data-booking-status="BOOKABLE"] [class*="HotelCard_info"]'
)
Expand Down Expand Up @@ -887,7 +890,7 @@ def test_presentation_4(self):
)
if price:
price_text = price.text
print("* %s (%s)" % (description.text, price_text))
print("* %s (%s)" % (description.text, price_text))

self.create_presentation(theme="serif", transition="none")
self.add_slide(
Expand Down
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ trio==0.27.0;python_version<"3.9"
trio>=0.31.0,<1;python_version>="3.9"
trio-websocket~=0.12.2
wsproto==1.2.0
websocket-client~=1.8.0
websocket-client~=1.8.0;python_version<"3.9"
websocket-client~=1.9.0;python_version>="3.9"
selenium==4.27.1;python_version<"3.9"
selenium==4.32.0;python_version>="3.9" and python_version<"3.10"
selenium==4.36.0;python_version>="3.10"
Expand All @@ -73,6 +74,7 @@ soupsieve~=2.8;python_version>="3.9"
beautifulsoup4~=4.14.2
pyotp==2.9.0
python-xlib==0.33;platform_system=="Linux"
PyAutoGUI>=0.9.54;platform_system=="Linux"
markdown-it-py==3.0.0;python_version<"3.10"
markdown-it-py==4.0.0;python_version>="3.10"
mdurl==0.1.2
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.42.2"
__version__ = "4.42.3"
5 changes: 4 additions & 1 deletion seleniumbase/core/sb_cdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,10 @@ def click(self, selector, timeout=None):
self.__slow_mode_pause_if_set()
element = self.find_element(selector, timeout=timeout)
element.scroll_into_view()
element.click()
if element.tag_name == "div" or element.tag_name == "input":
element.mouse_click() # Simulated click (not PyAutoGUI)
else:
element.click()
self.__slow_mode_pause_if_set()
self.loop.run_until_complete(self.page.wait())

Expand Down
Loading