Hi all !
I have one issue that I can't fix, maybe one of you have an idea on how to figure it out
While automating Chrome thanks to Chrome.ahk, I am facing an issue with a small popup window, the kind you get with a "Javascript: alert('Hello World!')" command.
This window will appear when I am sending a wrong request to my website.
I'd like to detect this window and close it ("ok" button).
What I tried:
- I am reading the URL thanks to PageInst.Evaluate("document.URL;").Value but when there is the popup, the ahk script stops, waiting endlessly for the return of the function that never comes. Thus I tried to add a TimeOut argument to the PageInst.Evaluate function in order to detect the popup when the timeout is reached. However, I could not make the Timeout work (available accordingly to Chrome Devtools). I tried a couple of different possibilities but it would basically look like this:
Code: Select all
Evaluate(JS,Timeout)
{
response := this.Call("Runtime.evaluate",
( LTrim Join
{
"expression": JS,
"objectGroup": "console",
"includeCommandLineAPI": Chrome.Jxon_True(),
"silent": Chrome.Jxon_False(),
"returnByValue": Chrome.Jxon_False(),
"userGesture": Chrome.Jxon_True(),
"awaitPromise": Chrome.Jxon_False(),
"timeout": Timeout
}
))
- Using ACC: thanks to the GetBrowserURL_ACC function (topic 637687), I can retrieve the URL of the page thanks to ACC. I noticed that when I was facing the popup, the function would return a blank window so I was using this until a new version of Chrome (I guess) that allow the function to return the URL despite of the popup.
I hope I was clear enough. If you have any suggestion that may help I would love to read it.
If you need clarifications, please let me know.