File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 1+ from seleniumbase import SB
2+
3+ with SB (uc = True , ad_block = True , test = True ) as sb :
4+ url = "https://www.alltrails.com/"
5+ sb .activate_cdp_mode (url )
6+ sb .sleep (1 )
7+ sb .click_if_visible ("button.osano-cm-close" )
8+ sb .sleep (0.5 )
9+ search_box = 'input[data-testid="homepage-search-box"]'
10+ search_term = "Thundering Brook Falls"
11+ sb .type (search_box , search_term + " Trail" )
12+ sb .sleep (1.5 )
13+ sb .click ('a span:contains("%s")' % search_term )
14+ sb .sleep (3.5 )
15+ sb .cdp .click ('button:contains("more")' )
16+ sb .sleep (0.7 )
17+ sb .click_if_visible ('button[data-testid="modal-close"]' )
18+ sb .sleep (0.7 )
19+ print ("Description: (%s)\n " % sb .get_text ("h1" ))
20+ print (sb .get_text ('div[class*="Description_expanded"]' ))
21+ sb .scroll_to_bottom ()
22+ sb .sleep (1.7 )
23+ sb .click_if_visible ('button[data-testid="modal-close"]' )
24+ sb .sleep (1.7 )
25+ summary = '[class*="ReviewSummary_summary"] span'
26+ print ("\n Review Summary:\n \n %s" % sb .get_text (summary ))
27+ reviews = sb .select_all ('p[class*="styles_reviewText"]' )
28+ print ("\n Reviews:" )
29+ for review in reviews :
30+ print ("\n " + review .text )
31+ folder = "images_exported"
32+ file_name = "thundering_brook_falls.png"
33+ sb .save_screenshot (file_name , folder , selector = "body" )
34+ print ('\n "./%s/%s" was saved!' % (folder , file_name ))
Original file line number Diff line number Diff line change 1+ """Test that CDP Mode can autodetect and use xpath selectors."""
2+ from seleniumbase import SB
3+
4+ with SB (uc = True , test = True ) as sb :
5+ url = "https://seleniumbase.io/demo_page"
6+ sb .activate_cdp_mode (url )
7+ sb .cdp .highlight ('//input[@id="myTextInput"]' )
8+ sb .cdp .type ('//*[@id="myTextInput"]' , "XPath Test!" )
9+ sb .sleep (0.5 )
10+ sb .cdp .highlight ('//button[contains(text(),"(Green)")]' )
11+ sb .cdp .click ('//button[starts-with(text(),"Click Me")]' )
12+ sb .cdp .assert_element ('//button[contains(., "Purple")]' )
13+ sb .sleep (0.5 )
14+ sb .cdp .highlight ("//table/tbody/tr/td/h3" )
15+ sb .cdp .highlight ("//table/tbody/tr[1]/td[2]/h2" )
16+ sb .cdp .assert_text ("SeleniumBase" , "//table//h2" )
You can’t perform that action at this time.
0 commit comments