File tree Expand file tree Collapse file tree 4 files changed +14
-9
lines changed
Expand file tree Collapse file tree 4 files changed +14
-9
lines changed Original file line number Diff line number Diff line change 66@decorators .print_runtime ("Geolocation CDP Example" )
77def main ():
88 url = "https://www.openstreetmap.org/"
9- sb = sb_cdp .Chrome (url , geoloc = (48.87645 , 2.26340 ))
9+ location = (48.87645 , 2.26340 )
10+ sb = sb_cdp .Chrome (url , geoloc = location , use_chromium = True )
1011 sb .sleep (2 )
1112 sb .click ('a[aria-label="Show My Location"]' )
1213 sb .assert_url_contains ("48.876450/2.263400" )
Original file line number Diff line number Diff line change 11"""Geolocation example with CDP Mode"""
22from seleniumbase import SB
33
4- with SB (uc = True , test = True ) as sb :
4+ with SB (uc = True , test = True , use_chromium = True ) as sb :
55 url = "https://www.openstreetmap.org/"
6- sb .activate_cdp_mode (url , geoloc = (31.774390 , 35.222450 ))
6+ location = (31.774390 , 35.222450 )
7+ sb .activate_cdp_mode (url , geoloc = location )
78 sb .click ('a[aria-label="Show My Location"]' )
89 sb .assert_url_contains ("31.774390/35.222450" )
910 sb .sleep (5 )
Original file line number Diff line number Diff line change 33with SB (uc = True , ad_block = True , test = True ) as sb :
44 url = "https://www.alltrails.com/"
55 sb .activate_cdp_mode (url )
6- sb .sleep (1 )
6+ sb .sleep (3.5 )
77 sb .click_if_visible ("button.osano-cm-close" )
88 sb .sleep (0.5 )
9- search_box = 'input[data-testid="homepage- search-box "]'
9+ search_box = 'input[aria-describedby=" search-instructions "]'
1010 search_term = "Thundering Brook Falls"
11+ sb .wait_for_element (search_box )
12+ sb .sleep (1.5 )
1113 sb .type (search_box , search_term + " Trail" )
1214 sb .sleep (1.5 )
1315 sb .click ('a span:contains("%s")' % search_term )
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ def test_geolocation(self):
2525 self .execute_cdp_cmd (
2626 "Browser.grantPermissions" ,
2727 {
28- "origin" : "https://www.openstreetmap .org/" ,
28+ "origin" : "https://www.randymajors .org/" ,
2929 "permissions" : ["geolocation" ],
3030 },
3131 )
@@ -37,9 +37,10 @@ def test_geolocation(self):
3737 "accuracy" : 100 ,
3838 },
3939 )
40- self .open ("https://www.openstreetmap.org/" )
41- self .click ('a[aria-label="Show My Location"]' )
42- self .assert_url_contains ("48.876450/2.263400" )
40+ self .open ("https://www.randymajors.org/what-time-zone-am-i-in" )
41+ self .ad_block ()
42+ self .assert_text ("Paris, France" , "#statecountrylabel" )
43+ self .assert_text ("Central European Standard Time" , "#currentlabel" )
4344 self .save_screenshot_to_logs ()
4445 if self .headed :
4546 self .sleep (4 )
You can’t perform that action at this time.
0 commit comments