Skip to content

Commit fba6658

Browse files
committed
Update CDP Mode examples
1 parent f00b74c commit fba6658

File tree

9 files changed

+84
-85
lines changed

9 files changed

+84
-85
lines changed

examples/cdp_mode/raw_albertsons.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@
55
sb.activate_cdp_mode(url)
66
sb.sleep(2.5)
77
sb.remove_element("div > div > article")
8-
sb.cdp.scroll_into_view('input[type="search"]')
8+
sb.scroll_into_view('input[type="search"]')
99
close_btn = ".notification-alert-wrapper__close-button"
10-
sb.cdp.click_if_visible(close_btn)
11-
sb.cdp.click("input#search-suggestion-input")
10+
sb.click_if_visible(close_btn)
11+
sb.click("input#search-suggestion-input")
1212
sb.sleep(0.2)
1313
search = "Avocado Smoked Salmon"
1414
required_text = "Salmon"
15-
sb.cdp.press_keys("input#search-suggestion-input", search)
15+
sb.press_keys("input#search-suggestion-input", search)
1616
sb.sleep(0.8)
17-
sb.cdp.click("#suggestion-0 a span")
17+
sb.click("#suggestion-0 a span")
1818
sb.sleep(0.8)
19-
sb.cdp.click_if_visible(close_btn)
20-
sb.sleep(2.8)
19+
sb.click_if_visible(close_btn)
20+
sb.sleep(3.2)
2121
print('*** Albertsons Search for "%s":' % search)
2222
print(' (Results must contain "%s".)' % required_text)
2323
unique_item_text = []
2424
item_selector = 'a[href*="/meal-plans-recipes/shop/"]'
25-
items = sb.cdp.find_elements(item_selector)
25+
items = sb.find_elements(item_selector)
2626
for item in items:
2727
sb.sleep(0.06)
2828
if required_text in item.text:

examples/cdp_mode/raw_cdp_copilot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from seleniumbase import sb_cdp
22

33
url = "https://copilot.microsoft.com/"
4-
sb = sb_cdp.Chrome(url, locale="en", guest=True)
4+
sb = sb_cdp.Chrome(url, locale="en")
55
textarea = "textarea#userInput"
66
sb.wait_for_element(textarea)
77
sb.sleep(1.5)

examples/cdp_mode/raw_cf_clearance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def get_cf_clearance_cookie(sb):
1212
url = "https://gitlab.com/users/sign_in"
1313
sb = sb_cdp.Chrome(url, incognito=True)
1414
sb.sleep(2.2) # Wait for CAPTCHA to load
15-
sb.gui_click_captcha() # (Only if found)
15+
sb.solve_captcha() # (Only if found)
1616
sb.sleep(2.2) # Wait for CAPTCHA success
1717
cf_cookie = get_cf_clearance_cookie(sb)
1818
if cf_cookie:

examples/cdp_mode/raw_copilot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from seleniumbase import SB
22

3-
with SB(uc=True, test=True, guest=True) as sb:
3+
with SB(uc=True, test=True, locale="en") as sb:
44
url = "https://copilot.microsoft.com/"
55
sb.activate_cdp_mode(url)
66
textarea = "textarea#userInput"

examples/cdp_mode/raw_driver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
url = "www.planetminecraft.com/account"
77
driver.uc_activate_cdp_mode(url)
88
driver.sleep(1)
9-
driver.cdp.solve_captcha()
9+
driver.solve_captcha()
1010
driver.wait_for_element_absent("input[disabled]")
1111
driver.sleep(2)

examples/cdp_mode/raw_elal.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
url = "www.elal.com/flight-deals/en-us/flights-from-boston-to-tel-aviv"
77
sb.activate_cdp_mode(url)
88
sb.sleep(3)
9-
sb.cdp.click('label:contains("Departure date")')
9+
sb.click('label:contains("Departure date")')
1010
sb.sleep(1)
1111
today = datetime.date.today()
1212
days_ahead = (4 - today.weekday() + 7) % 7
@@ -25,21 +25,21 @@
2525
sb.sleep(1)
2626
sb.cdp.gui_press_keys("\b" * 10 + formatted_date + "\n")
2727
sb.sleep(1)
28-
sb.cdp.click('button[data-att="done"]')
28+
sb.click('button[data-att="done"]')
2929
sb.sleep(1)
30-
sb.cdp.click('button[data-att="search"]')
30+
sb.click('button[data-att="search"]')
3131
sb.sleep(5)
32-
sb.cdp.click_if_visible("#onetrust-close-btn-container button")
32+
sb.click_if_visible("#onetrust-close-btn-container button")
3333
sb.sleep(1)
3434
view_other_dates = 'button[aria-label*="viewOtherDates.cta"]'
35-
if sb.cdp.is_element_visible(view_other_dates):
36-
sb.cdp.click(view_other_dates)
35+
if sb.is_element_visible(view_other_dates):
36+
sb.click(view_other_dates)
3737
sb.sleep(5)
3838
if sb.is_element_visible("flexible-search-calendar"):
3939
print("*** Flight Calendar for El Al (Boston to Tel Aviv): ***")
40-
print(sb.cdp.get_text("flexible-search-calendar"))
40+
print(sb.get_text("flexible-search-calendar"))
4141
prices = []
42-
elements = sb.cdp.find_elements("span.matric-cell__content__price")
42+
elements = sb.find_elements("span.matric-cell__content__price")
4343
if elements:
4444
print("*** Prices List: ***")
4545
for element in elements:
@@ -50,32 +50,32 @@
5050
print("*** Lowest Price: ***")
5151
lowest_price = prices[0]
5252
print(lowest_price)
53-
sb.cdp.scroll_down(12)
53+
sb.scroll_down(12)
5454
sb.sleep(1)
55-
sb.cdp.find_element_by_text(lowest_price).click()
55+
sb.find_element_by_text(lowest_price).click()
5656
sb.sleep(2)
5757
search_cell = 'button[aria-label*="Search.cell.buttonTitle"]'
58-
sb.cdp.scroll_into_view(search_cell)
58+
sb.scroll_into_view(search_cell)
5959
sb.sleep(1)
60-
sb.cdp.click(search_cell)
60+
sb.click(search_cell)
6161
sb.sleep(5)
6262
else:
6363
print("*** Lowest Prices: ***")
6464
departure_prices = "#uiFlightPanel0 div.ui-bound__price__value"
6565
return_prices = "#uiFlightPanel1 div.ui-bound__price__value"
66-
elements = sb.cdp.find_elements(departure_prices)
66+
elements = sb.find_elements(departure_prices)
6767
for element in elements:
6868
if "lowest price" in element.text:
6969
print("Departure Flight:")
7070
print(element.text)
7171
break
72-
elements = sb.cdp.find_elements(return_prices)
72+
elements = sb.find_elements(return_prices)
7373
for element in elements:
7474
if "lowest price" in element.text:
7575
print("Return Flight:")
7676
print(element.text)
7777
break
78-
dates = sb.cdp.find_elements('div[class*="flight-date"]')
78+
dates = sb.find_elements('div[class*="flight-date"]')
7979
if len(dates) == 2:
8080
print("*** Departure Date: ***")
8181
print(dates[0].text)

examples/cdp_mode/raw_nordstrom.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
url = "https://www.nordstrom.com/"
55
sb.activate_cdp_mode(url)
66
sb.sleep(2.2)
7-
sb.cdp.click("input#keyword-search-input")
7+
sb.click("input#keyword-search-input")
88
sb.sleep(0.8)
99
search = "cocktail dresses for women teal"
10-
sb.cdp.press_keys("input#keyword-search-input", search + "\n")
10+
sb.press_keys("input#keyword-search-input", search + "\n")
1111
sb.sleep(2.2)
1212
for i in range(17):
13-
sb.cdp.scroll_down(16)
13+
sb.scroll_down(16)
1414
sb.sleep(0.14)
1515
print('*** Nordstrom Search for "%s":' % search)
1616
unique_item_text = []
17-
items = sb.cdp.find_elements("article")
17+
items = sb.find_elements("article")
1818
for item in items:
1919
description = item.querySelector("article h3")
2020
if description and description.text not in unique_item_text:

0 commit comments

Comments
 (0)