Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3c7c0ac

Browse filesBrowse files
committed
Update the pure CDP Mode examples
1 parent e720521 commit 3c7c0ac
Copy full SHA for 3c7c0ac

File tree

Expand file treeCollapse file tree

11 files changed

+15
-1
lines changed
Filter options
Expand file treeCollapse file tree

11 files changed

+15
-1
lines changed

‎examples/cdp_mode/raw_async.py

Copy file name to clipboardExpand all lines: examples/cdp_mode/raw_async.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ async def main():
1616
time.sleep(1)
1717
await element.send_keys_async("Boston")
1818
time.sleep(2)
19+
driver.stop()
1920

2021
if __name__ == "__main__":
2122
# Call an async function with awaited methods
@@ -39,6 +40,7 @@ async def main():
3940
time.sleep(2)
4041
print(loop.run_until_complete(page.evaluate("document.title")))
4142
time.sleep(1)
43+
driver.stop()
4244

4345
# Call CDP methods via the simplified SB CDP API
4446
sb = sb_cdp.Chrome("https://www.priceline.com/")
@@ -62,3 +64,4 @@ async def main():
6264
cards = sb.select_all('span[data-automation*="product-list-card"]')
6365
for card in cards:
6466
print("* %s" % card.text)
67+
sb.driver.stop()

‎examples/cdp_mode/raw_cdp.py

Copy file name to clipboardExpand all lines: examples/cdp_mode/raw_cdp.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def main():
3030
cards = sb.select_all('span[data-automation*="product-list-card"]')
3131
for card in cards:
3232
print("* %s" % card.text)
33+
sb.driver.stop()
3334

3435

3536
if __name__ == "__main__":

‎examples/cdp_mode/raw_cdp_extended.py

Copy file name to clipboardExpand all lines: examples/cdp_mode/raw_cdp_extended.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@
2121
sb.gui_drag_and_drop("img#logo", "div#drop2")
2222
sb.nested_click("iframe#myFrame3", ".fBox")
2323
sb.sleep(2)
24+
sb.driver.stop()

‎examples/cdp_mode/raw_cdp_nike.py

Copy file name to clipboardExpand all lines: examples/cdp_mode/raw_cdp_nike.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
print('**** Found results for "%s": ****' % search)
1313
for element in elements:
1414
print("* " + element.text)
15+
sb.driver.stop()

‎examples/cdp_mode/raw_cookies_async.py

Copy file name to clipboardExpand all lines: examples/cdp_mode/raw_cookies_async.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ async def get_login_cookies():
1616
element = await page.select('input[type="submit"]')
1717
await element.click_async()
1818
cookies = await driver.cookies.get_all()
19-
await page.close()
19+
driver.stop()
2020
return cookies
2121

2222

@@ -30,6 +30,7 @@ async def login_with_cookies(cookies):
3030
await driver.get(url_2)
3131
await page.select("div.inventory_list")
3232
time.sleep(2)
33+
driver.stop()
3334

3435

3536
if __name__ == "__main__":

‎examples/cdp_mode/raw_geolocation.py

Copy file name to clipboardExpand all lines: examples/cdp_mode/raw_geolocation.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def main():
1111
sb.click('a[aria-label="Show My Location"]')
1212
sb.assert_url_contains("48.876450/2.263400")
1313
sb.sleep(5)
14+
sb.driver.stop()
1415

1516

1617
if __name__ == "__main__":

‎examples/cdp_mode/raw_multi_async.py

Copy file name to clipboardExpand all lines: examples/cdp_mode/raw_multi_async.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ async def main(url):
1515
button = await page.select("button")
1616
await button.click_async()
1717
await page.sleep(2)
18+
driver.stop()
1819

1920

2021
def set_up_loop(url):

‎examples/cdp_mode/raw_proxy.py

Copy file name to clipboardExpand all lines: examples/cdp_mode/raw_proxy.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def main():
4444
data.append(row.strip())
4545
print("\n".join(data).replace('\n"', ' "'))
4646
sb.sleep(3)
47+
sb.driver.stop()
4748

4849

4950
if __name__ == "__main__":

‎examples/cdp_mode/raw_req_async.py

Copy file name to clipboardExpand all lines: examples/cdp_mode/raw_req_async.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ async def start_test(self):
3636
url = "https://gettyimages.com/photos/firefly-2003-nathan"
3737
await driver.get(url)
3838
await asyncio.sleep(5)
39+
driver.stop()
3940

4041

4142
@decorators.print_runtime("RequestPausedTest")

‎examples/cdp_mode/raw_timezone.py

Copy file name to clipboardExpand all lines: examples/cdp_mode/raw_timezone.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def main():
2828
sb.remove_elements("#right-sidebar")
2929
sb.remove_elements('[id*="Footer"]')
3030
sb.sleep(6)
31+
sb.driver.stop()
3132

3233

3334
if __name__ == "__main__":

‎help_docs/syntax_formats.md

Copy file name to clipboardExpand all lines: help_docs/syntax_formats.md
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,7 @@ async def main():
10331033
time.sleep(1)
10341034
await element.send_keys_async("Boston")
10351035
time.sleep(2)
1036+
driver.stop()
10361037

10371038
if __name__ == "__main__":
10381039
loop = asyncio.new_event_loop()
@@ -1075,6 +1076,7 @@ def main():
10751076
cards = sb.select_all('span[data-automation*="product-list-card"]')
10761077
for card in cards:
10771078
print("* %s" % card.text)
1079+
sb.driver.stop()
10781080

10791081

10801082
if __name__ == "__main__":

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.