Skip to content

Commit 6f2ed08

Browse files
committed
Update examples
1 parent 4de63c8 commit 6f2ed08

2 files changed

Lines changed: 74 additions & 46 deletions

File tree

examples/cdp_mode/raw_demo_site.py

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,72 @@
1-
"""Example of using various CDP Mode commands via sb.cdp"""
1+
"""Example of using various CDP Mode commands."""
22
from seleniumbase import SB
33

44
with SB(uc=True, test=True) as sb:
55
sb.activate_cdp_mode()
6-
sb.cdp.goto("https://seleniumbase.io/demo_page")
6+
sb.goto("https://seleniumbase.io/demo_page")
77

88
# Assert various things
9-
sb.cdp.assert_title("Web Testing Page")
10-
sb.cdp.assert_element("tbody#tbodyId")
11-
sb.cdp.assert_text("Demo Page", "h1")
9+
sb.assert_title("Web Testing Page")
10+
sb.assert_element("tbody#tbodyId")
11+
sb.assert_text("Demo Page", "h1")
1212

1313
# Type text into various text fields and then assert
14-
sb.cdp.type("#myTextInput", "This is Automated")
15-
sb.cdp.type("textarea.area1", "Testing Time!\n")
16-
sb.cdp.type('[name="preText2"]', "Typing Text!")
17-
sb.cdp.assert_text("This is Automated", "#myTextInput")
18-
sb.cdp.assert_text("Testing Time!\n", "textarea.area1")
19-
sb.cdp.assert_text("Typing Text!", '[name="preText2"]')
14+
sb.type("#myTextInput", "This is Automated")
15+
sb.type("textarea.area1", "Testing Time!\n")
16+
sb.type('[name="preText2"]', "Typing Text!")
17+
sb.assert_text("This is Automated", "#myTextInput")
18+
sb.assert_text("Testing Time!\n", "textarea.area1")
19+
sb.assert_text("Typing Text!", '[name="preText2"]')
2020

2121
# Hover & click a dropdown element and assert results
22-
sb.cdp.assert_text("Automation Practice", "h3")
23-
sb.cdp.hover_and_click("#myDropdown", "#dropOption2")
24-
sb.cdp.assert_text("Link Two Selected", "h3")
22+
sb.assert_text("Automation Practice", "h3")
23+
sb.hover_and_click("#myDropdown", "#dropOption2")
24+
sb.assert_text("Link Two Selected", "h3")
2525

2626
# Click a button and then verify the expected results
27-
sb.cdp.assert_text("This Text is Green", "#pText")
28-
sb.cdp.click('button:contains("Click Me")')
29-
sb.cdp.assert_text("This Text is Purple", "#pText")
27+
sb.assert_text("This Text is Green", "#pText")
28+
sb.click('button:contains("Click Me")')
29+
sb.assert_text("This Text is Purple", "#pText")
3030

3131
# Verify that a slider control updates a progress bar
32-
sb.cdp.assert_element('progress[value="50"]')
33-
sb.cdp.set_value("input#mySlider", "100")
34-
sb.cdp.assert_element('progress[value="100"]')
32+
sb.assert_element('progress[value="50"]')
33+
sb.set_value("input#mySlider", "100")
34+
sb.assert_element('progress[value="100"]')
3535

3636
# Verify that a "select" option updates a meter bar
37-
sb.cdp.assert_element('meter[value="0.25"]')
38-
sb.cdp.select_option_by_text("#mySelect", "Set to 75%")
39-
sb.cdp.assert_element('meter[value="0.75"]')
37+
sb.assert_element('meter[value="0.25"]')
38+
sb.select_option_by_text("#mySelect", "Set to 75%")
39+
sb.assert_element('meter[value="0.75"]')
4040

4141
# Verify that clicking a radio button selects it
42-
sb.cdp.assert_false(sb.cdp.is_selected("#radioButton2"))
43-
sb.cdp.click("#radioButton2")
44-
sb.cdp.assert_true(sb.cdp.is_selected("#radioButton2"))
42+
sb.assert_false(sb.is_selected("#radioButton2"))
43+
sb.click("#radioButton2")
44+
sb.assert_true(sb.is_selected("#radioButton2"))
4545

4646
# Verify that clicking a checkbox makes it selected
47-
sb.cdp.assert_element_not_visible("img#logo")
48-
sb.cdp.assert_false(sb.cdp.is_selected("#checkBox1"))
49-
sb.cdp.click("#checkBox1")
50-
sb.cdp.assert_true(sb.cdp.is_selected("#checkBox1"))
51-
sb.cdp.assert_element("img#logo")
47+
sb.assert_element_not_visible("img#logo")
48+
sb.assert_false(sb.is_selected("#checkBox1"))
49+
sb.click("#checkBox1")
50+
sb.assert_true(sb.is_selected("#checkBox1"))
51+
sb.assert_element("img#logo")
5252

5353
# Verify clicking on multiple elements with one call
54-
sb.cdp.assert_false(sb.cdp.is_selected("#checkBox2"))
55-
sb.cdp.assert_false(sb.cdp.is_selected("#checkBox3"))
56-
sb.cdp.assert_false(sb.cdp.is_selected("#checkBox4"))
57-
sb.cdp.click_visible_elements("input.checkBoxClassB")
58-
sb.cdp.assert_true(sb.cdp.is_selected("#checkBox2"))
59-
sb.cdp.assert_true(sb.cdp.is_selected("#checkBox3"))
60-
sb.cdp.assert_true(sb.cdp.is_selected("#checkBox4"))
54+
sb.assert_false(sb.is_selected("#checkBox2"))
55+
sb.assert_false(sb.is_selected("#checkBox3"))
56+
sb.assert_false(sb.is_selected("#checkBox4"))
57+
sb.click_visible_elements("input.checkBoxClassB")
58+
sb.assert_true(sb.is_selected("#checkBox2"))
59+
sb.assert_true(sb.is_selected("#checkBox3"))
60+
sb.assert_true(sb.is_selected("#checkBox4"))
6161

6262
# Verify Drag and Drop
63-
sb.cdp.assert_element_not_visible("div#drop2 img#logo")
64-
sb.cdp.gui_drag_and_drop("img#logo", "div#drop2")
65-
sb.cdp.assert_element("div#drop2 img#logo")
63+
sb.assert_element_not_visible("div#drop2 img#logo")
64+
sb.gui_drag_and_drop("img#logo", "div#drop2")
65+
sb.assert_element("div#drop2 img#logo")
6666

6767
# Click inside an iframe and test highlighting
68-
sb.cdp.flash("iframe#myFrame3")
69-
sb.cdp.sleep(1)
70-
sb.cdp.nested_click("iframe#myFrame3", ".fBox")
71-
sb.cdp.sleep(0.5)
72-
sb.cdp.highlight("iframe#myFrame3")
68+
sb.flash("iframe#myFrame3")
69+
sb.sleep(1)
70+
sb.nested_click("iframe#myFrame3", ".fBox")
71+
sb.sleep(0.5)
72+
sb.highlight("iframe#myFrame3")

examples/cdp_mode/raw_lesfurets.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from seleniumbase import SB
2+
3+
with SB(uc=True, ad_block=True, test=True) as sb:
4+
sb.activate_cdp_mode()
5+
sb.goto("https://www.lesfurets.com/")
6+
sb.sleep(2)
7+
sb.click_if_visible("button#didomi-notice-agree-button", timeout=3)
8+
sb.sleep(1)
9+
sb.click('p:contains("Assurance moto")')
10+
sb.click('label[for="CYLINDREE_CYLINDREE_INF"]')
11+
sb.click('label[for="VEH_POSSESSION_false"]')
12+
sb.click('label[for="VEH_TYPE_ACQUISITION_premier"]')
13+
sb.click("button.userValidation")
14+
sb.click('div[data-testid="DATE_CIRCULATION_VEHICULE-month"]')
15+
sb.click('span:contains("Janvier")')
16+
sb.click('div[data-testid="DATE_CIRCULATION_VEHICULE-year"]')
17+
sb.click('div[data-value="2026"] span')
18+
sb.click('div[data-testid="ACHAT_PREVU_VEHICULE-month"]')
19+
sb.click('span:contains("Mars")')
20+
sb.click('div[data-testid="ACHAT_PREVU_VEHICULE-year"]')
21+
sb.click('div[data-value="2027"] span')
22+
sb.click('div[data-testid="PERMIS"]')
23+
sb.click('span:contains("Aucun")')
24+
sb.click("button.DaisyBlockView-next")
25+
sb.assert_element("div.VehiculePickerField")
26+
sb.click('label:contains("Choisir votre véhicule")')
27+
sb.type("input#modele_picker", "2TWENTY")
28+
sb.sleep(3)

0 commit comments

Comments
 (0)