Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mdmintz committed Jan 9, 2025
1 parent b991086 commit 5911c5d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion examples/cdp_mode/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,16 +274,18 @@ 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, 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.cdp.mouse_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.sleep(3.8)
sb.cdp.remove_elements('[data-testid="skyline-ad"]')
print('*** Walmart Search for "%s":' % search)
print(' (Results must contain "%s".)' % required_text)
unique_item_text = []
Expand Down
5 changes: 4 additions & 1 deletion examples/cdp_mode/raw_southwest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,8 @@
arrives = info.split("Arrives")[-1].split("M")[0].strip() + "M"
stops = flight.query_selector(".flight-stops-badge").text
duration = flight.query_selector('[class*="flight-duration"]').text
price = flight.query_selector('span.currency span[aria-hidden]').text
p_elm = flight.query_selector('span.currency span[aria-hidden]')
if not p_elm:
continue
price = p_elm.text
print(f"* {day}, {departs} -> {arrives} ({stops}: {duration}) {price}")
4 changes: 3 additions & 1 deletion examples/cdp_mode/raw_walmart.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
from seleniumbase import SB

with SB(uc=True, test=True, locale_code="en", ad_block=True) as 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.cdp.mouse_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.sleep(3.8)
sb.cdp.remove_elements('[data-testid="skyline-ad"]')
print('*** Walmart Search for "%s":' % search)
print(' (Results must contain "%s".)' % required_text)
unique_item_text = []
Expand Down

0 comments on commit 5911c5d

Please sign in to comment.