Skip to content

Commit 279ca93

Browse files
committedJan 10, 2025
Update examples
1 parent 4a24e26 commit 279ca93

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed
 

‎examples/cdp_mode/ReadMe.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb:
235235
url = "https://www.bestwestern.com/en_US.html"
236236
sb.activate_cdp_mode(url)
237237
sb.sleep(2.5)
238-
sb.cdp.click_if_visible("div.onetrust-close-btn-handler")
238+
sb.cdp.click_if_visible(".onetrust-close-btn-handler")
239239
sb.sleep(1)
240240
sb.cdp.click("input#destination-input")
241241
sb.sleep(2)
@@ -250,7 +250,9 @@ with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb:
250250
sb.sleep(2.5)
251251
print("Best Western Hotels in %s:" % location)
252252
summary_details = sb.cdp.get_text("#summary-details-column")
253-
dates = summary_details.split("ROOM")[0].split("DATES")[-1].strip()
253+
dates = summary_details.split("DESTINATION")[-1]
254+
dates = dates.split(" CHECK-OUT")[0].strip() + " CHECK-OUT"
255+
dates = dates.replace(" ", " ")
254256
print("(Dates: %s)" % dates)
255257
flip_cards = sb.cdp.select_all(".flipCard")
256258
for i, flip_card in enumerate(flip_cards):

‎examples/cdp_mode/raw_bestwestern.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
url = "https://www.bestwestern.com/en_US.html"
55
sb.activate_cdp_mode(url)
66
sb.sleep(2.5)
7-
sb.cdp.click_if_visible("div.onetrust-close-btn-handler")
7+
sb.cdp.click_if_visible(".onetrust-close-btn-handler")
88
sb.sleep(1)
99
sb.cdp.click("input#destination-input")
1010
sb.sleep(2)
@@ -19,7 +19,9 @@
1919
sb.sleep(2.5)
2020
print("Best Western Hotels in %s:" % location)
2121
summary_details = sb.cdp.get_text("#summary-details-column")
22-
dates = summary_details.split("ROOM")[0].split("DATES")[-1].strip()
22+
dates = summary_details.split("DESTINATION")[-1]
23+
dates = dates.split(" CHECK-OUT")[0].strip() + " CHECK-OUT"
24+
dates = dates.replace(" ", " ")
2325
print("(Dates: %s)" % dates)
2426
flip_cards = sb.cdp.select_all(".flipCard")
2527
for i, flip_card in enumerate(flip_cards):

‎examples/presenter/uc_presentation_4.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -516,17 +516,19 @@ def test_presentation_4(self):
516516
)
517517
self.begin_presentation(filename="uc_presentation.html")
518518

519-
with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb:
519+
with SB(uc=True, test=True, ad_block=True) as sb:
520520
url = "https://www.walmart.com/"
521521
sb.activate_cdp_mode(url)
522522
sb.sleep(2.5)
523+
sb.cdp.click_if_visible('[data-automation-id*="close-mark"]')
523524
sb.cdp.mouse_click('input[aria-label="Search"]')
524525
sb.sleep(1.2)
525526
search = "Settlers of Catan Board Game"
526527
required_text = "Catan"
527528
sb.cdp.press_keys('input[aria-label="Search"]', search + "\n")
528529
sb.sleep(3.8)
529-
print('\n\n*** Walmart Search for "%s":' % search)
530+
sb.cdp.remove_elements('[data-testid="skyline-ad"]')
531+
print('*** Walmart Search for "%s":' % search)
530532
print(' (Results must contain "%s".)' % required_text)
531533
unique_item_text = []
532534
items = sb.cdp.find_elements('div[data-testid="list-view"]')
@@ -642,7 +644,7 @@ def test_presentation_4(self):
642644
sb.cdp.click('button[data-testid="submit"]')
643645
sb.sleep(3.5)
644646
sb.connect()
645-
sb.sleep(2.5)
647+
sb.sleep(4.2)
646648
for window in sb.driver.window_handles:
647649
sb.switch_to_window(window)
648650
if "/buy/flights" in sb.get_current_url():
@@ -708,6 +710,7 @@ def test_presentation_4(self):
708710
if "Avg/Night" in info and not info.startswith("Rates from"):
709711
name = info.split(" (")[0]
710712
name = name.split(" + ")[0].split(" Award Cat")[0]
713+
name = name.split(" Rates from :")[0]
711714
price = "?"
712715
if "Rates from : " in info:
713716
price = info.split("Rates from : ")[1]
@@ -728,7 +731,7 @@ def test_presentation_4(self):
728731
url = "https://www.bestwestern.com/en_US.html"
729732
sb.activate_cdp_mode(url)
730733
sb.sleep(2.5)
731-
sb.cdp.click_if_visible("div.onetrust-close-btn-handler")
734+
sb.cdp.click_if_visible(".onetrust-close-btn-handler")
732735
sb.sleep(1)
733736
sb.cdp.click("input#destination-input")
734737
sb.sleep(2)
@@ -741,9 +744,11 @@ def test_presentation_4(self):
741744
sb.sleep(4)
742745
sb.cdp.click("label#available-label")
743746
sb.sleep(2.5)
744-
print("\n\nBest Western Hotels in %s:" % location)
747+
print("Best Western Hotels in %s:" % location)
745748
summary_details = sb.cdp.get_text("#summary-details-column")
746-
dates = summary_details.split("ROOM")[0].split("DATES")[-1].strip()
749+
dates = summary_details.split("DESTINATION")[-1]
750+
dates = dates.split(" CHECK-OUT")[0].strip() + " CHECK-OUT"
751+
dates = dates.replace(" ", " ")
747752
print("(Dates: %s)" % dates)
748753
flip_cards = sb.cdp.select_all(".flipCard")
749754
for i, flip_card in enumerate(flip_cards):

0 commit comments

Comments
 (0)
Please sign in to comment.