Skip to content

Commit 633f4ec

Browse files
committed
Update the ChatGPT test
1 parent f6998b5 commit 633f4ec

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

examples/cdp_mode/raw_chatgpt.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from contextlib import suppress
12
from seleniumbase import SB
23

34
with SB(uc=True, test=True, ad_block=True) as sb:
@@ -6,8 +7,11 @@
67
query = "Compare Playwright to SeleniumBase in under 178 words"
78
sb.type("#prompt-textarea", query)
89
sb.click('button[data-testid="send-button"]')
9-
print('Input for ChatGPT:\n"%s"' % query)
10-
sb.sleep(12)
10+
print('*** Input for ChatGPT: ***\n"%s"' % query)
11+
with suppress(Exception):
12+
# The "Send" button reappears when ChatGPT is done typing a response
13+
sb.wait_for_element('button[data-testid="send-button"]', timeout=22)
1114
chat = sb.find_element('[data-message-author-role="assistant"] .markdown')
1215
soup = sb.get_beautiful_soup(chat.get_html()).get_text("\n").strip()
13-
print("Response from ChatGPT:\n%s" % soup.replace("\n:", ":"))
16+
print("*** Response from ChatGPT: ***\n%s" % soup.replace("\n:", ":"))
17+
sb.sleep(3)

0 commit comments

Comments
 (0)