Skip to content

Commit 5911c5d

Browse files
committed
Update examples
1 parent b991086 commit 5911c5d

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

examples/cdp_mode/ReadMe.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,16 +274,18 @@ with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb:
274274
```python
275275
from seleniumbase import SB
276276

277-
with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb:
277+
with SB(uc=True, test=True, ad_block=True) as sb:
278278
url = "https://www.walmart.com/"
279279
sb.activate_cdp_mode(url)
280280
sb.sleep(2.5)
281+
sb.cdp.click_if_visible('[data-automation-id*="close-mark"]')
281282
sb.cdp.mouse_click('input[aria-label="Search"]')
282283
sb.sleep(1.2)
283284
search = "Settlers of Catan Board Game"
284285
required_text = "Catan"
285286
sb.cdp.press_keys('input[aria-label="Search"]', search + "\n")
286287
sb.sleep(3.8)
288+
sb.cdp.remove_elements('[data-testid="skyline-ad"]')
287289
print('*** Walmart Search for "%s":' % search)
288290
print(' (Results must contain "%s".)' % required_text)
289291
unique_item_text = []

examples/cdp_mode/raw_southwest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,8 @@
3636
arrives = info.split("Arrives")[-1].split("M")[0].strip() + "M"
3737
stops = flight.query_selector(".flight-stops-badge").text
3838
duration = flight.query_selector('[class*="flight-duration"]').text
39-
price = flight.query_selector('span.currency span[aria-hidden]').text
39+
p_elm = flight.query_selector('span.currency span[aria-hidden]')
40+
if not p_elm:
41+
continue
42+
price = p_elm.text
4043
print(f"* {day}, {departs} -> {arrives} ({stops}: {duration}) {price}")

examples/cdp_mode/raw_walmart.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
from seleniumbase import SB
22

3-
with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb:
3+
with SB(uc=True, test=True, ad_block=True) as sb:
44
url = "https://www.walmart.com/"
55
sb.activate_cdp_mode(url)
66
sb.sleep(2.5)
7+
sb.cdp.click_if_visible('[data-automation-id*="close-mark"]')
78
sb.cdp.mouse_click('input[aria-label="Search"]')
89
sb.sleep(1.2)
910
search = "Settlers of Catan Board Game"
1011
required_text = "Catan"
1112
sb.cdp.press_keys('input[aria-label="Search"]', search + "\n")
1213
sb.sleep(3.8)
14+
sb.cdp.remove_elements('[data-testid="skyline-ad"]')
1315
print('*** Walmart Search for "%s":' % search)
1416
print(' (Results must contain "%s".)' % required_text)
1517
unique_item_text = []

0 commit comments

Comments
 (0)