Skip to content

Commit c8b550e

Browse files
committed
Update examples
1 parent a75eadb commit c8b550e

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

examples/cdp_mode/raw_geolocation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
@decorators.print_runtime("Geolocation CDP Example")
77
def 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")
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
"""Geolocation example with CDP Mode"""
22
from 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)

examples/cdp_mode/raw_trails.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
with 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)

examples/test_geolocation.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff 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)

0 commit comments

Comments
 (0)