Skip to content

Commit 10bb59e

Browse files
committed
Add an example
1 parent 9faf8d9 commit 10bb59e

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

examples/raw_cdp_copilot.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from seleniumbase import sb_cdp
2+
3+
try:
4+
url = "https://copilot.microsoft.com/"
5+
sb = sb_cdp.Chrome(url, locale="en", guest=True)
6+
textarea = "textarea#userInput"
7+
sb.wait_for_element(textarea)
8+
sb.sleep(1.5)
9+
sb.click_if_visible('[aria-label="Dismiss"]')
10+
sb.sleep(0.5)
11+
sb.click('button[data-testid*="chat-mode-"]')
12+
sb.sleep(1.1)
13+
sb.click('button[title="Think Deeper"]')
14+
sb.sleep(1.1)
15+
query = "How to start automating with SeleniumBase?"
16+
sb.press_keys(textarea, query)
17+
sb.sleep(1.1)
18+
sb.click('button[data-testid="submit-button"]')
19+
sb.sleep(2.5)
20+
sb.gui_click_captcha()
21+
sb.sleep(2.5)
22+
sb.gui_click_captcha()
23+
sb.sleep(3.5)
24+
stop_button = '[data-testid="stop-button"]'
25+
thumbs_up = 'button[data-testid*="-thumbs-up-"]'
26+
sb.wait_for_element_absent(stop_button, timeout=45)
27+
sb.wait_for_element(thumbs_up, timeout=20)
28+
sb.sleep(0.6)
29+
sb.click('button[data-testid*="scroll-to-bottom"]')
30+
sb.sleep(2.2)
31+
folder = "downloaded_files"
32+
file_name = "copilot_results.html"
33+
sb.save_as_html(file_name, folder)
34+
print('"./%s/%s" was saved!' % (folder, file_name))
35+
sb.driver.stop()
36+
except Exception:
37+
print("Something failed!")

0 commit comments

Comments
 (0)