Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Wait for the button to disappear on the webpage
#1
I need to display a message box when the "Stop generating" disappears. The following code is not working. Below is a GIF demo.
https://i.ibb.co/mbj1s9P/aaa.gif

Code:
Copy      Help
// script "chatGPT_T.cs"
//.
script.setup(trayIcon: true, sleepExit: true);
//..

var w = wnd.find(1, "*- Google Chrome", "Chrome_WidgetWin_1");

//send text
var e = w.Elm["web:TEXT", "Message ChatGPT…"].Find(1);
e.MouseClick(); keys.send("Ctrl+A", "!c# and powershell diff");

//click send-button
var e2 = w.Elm["web:BUTTON", prop: "@data-testid=send-button"].Find(1);
e2.MouseClick();

2.s();

var e3 = w.Elm["web:BUTTON", "Stop generating", "@aria-label=Stop generating"].Find(1);
wait.until(30, () => !e3.IsInvisible);

dialog.show("ok");

There may be multiple ways to achieve the goal
#2
Code:
Copy      Help
// script ""
var w = wnd.find(1, "*- Google Chrome", "Chrome_WidgetWin_1");

//prompt
var e = w.Elm["web:TEXT", "Message ChatGPT…"].Find(1);
e.SendKeys("Ctrl+A", "!c# and powershell diff", "Enter");

//wait for full response
w.Elm["web:BUTTON", "Stop generating"].Wait(5); //wait for button
wait.until(300, () => !w.Elm["web:BUTTON", "Stop generating"].Exists()); //wait until button disappears

dialog.show("ok");

or

Code:
Copy      Help
// script ""
var w = wnd.find(1, "*- Google Chrome", "Chrome_WidgetWin_1");

//prompt
var e = w.Elm["web:TEXT", "Message ChatGPT…"].Find(1);
e.SendKeys("Ctrl+A", "!c# and powershell diff", "Enter");

//wait for full response
var f = new elmFinder("web:BUTTON", "Stop generating").In(w);
f.Wait(5); //wait for button
wait.until(300, () => !f.Exists()); //wait until button disappears

dialog.show("ok");
#3
Thank you for your help, great tips!
I want to click the 'new chat' button, but the captured results are inconsistent, I am unable to use other properties of this object
#4
As always, try navig or Add to path or skip.

The best for automation are Chromium-based browsers. Firefox slower and no HTML attributes.
#5
To make it more complicated, when the sidebar is visible, the button is in other place.
Here is a simpler solution:
 
Code:
Copy      Help
keys.send("Ctrl+L"); //focus address bar
clipboard.paste("https://chat.openai.com/");
keys.send("Del Enter");

or
Code:
Copy      Help
keys.send("Ctrl+L", "!https://chat.openai.com/", "Del Enter");
#6
The plan is more suitable. Thanks again


Forum Jump:


Users browsing this thread: 1 Guest(s)