File tree 1 file changed +7
-3
lines changed
1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change
1
+ from contextlib import suppress
1
2
from seleniumbase import SB
2
3
3
4
with SB (uc = True , test = True , ad_block = True ) as sb :
6
7
query = "Compare Playwright to SeleniumBase in under 178 words"
7
8
sb .type ("#prompt-textarea" , query )
8
9
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 )
11
14
chat = sb .find_element ('[data-message-author-role="assistant"] .markdown' )
12
15
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 )
You can’t perform that action at this time.
0 commit comments