Running javascript using StoreEval

I am experiencing an issue with the newest version where I am no longer to run javascript confirm or alert dialogues using storeEval. I’ve tried using archived versions of Kantu and the javascript still works so it isn’t an issue directly with Chrome or Firefox (or both).

Here is an example that works in 3.0.3 but not 3.1.8:

{
“CreationDate”: “2018-8-30”,
“Commands”: [
{
“Command”: “open”,
“Target”: “https://www.google.com”,
“Value”: “”
},
{
“Command”: “waitForPageToLoad”,
“Target”: “”,
“Value”: “”
},
{
“Command”: “selectFrame”,
“Target”: “relative=top”,
“Value”: “”
},
{
“Command”: “selectFrame”,
“Target”: “index=0”,
“Value”: “”
},
{
“Command”: “storeEval”,
“Target”: “window.confirm(“Hello”)”,
“Value”: “confirmValue”
}
]
}

I confirmed the issue, thanks for reporting it. We will fix it asap.

It turns out that this is not a bug, but a feature, see explanation below:

That 3.1.3 shows you that confirmation box is a bug, and the last update kind of fixed that. The the reason why it doesn’t (should) show confirm or alert, is because we hack confirm / prompt / alert (window.confirm) during replay to support assertAlert / assertConfirmation / assertPrompt.

In the classic Firefox Selenium IDE you needed to add a chooseOkOnNextConfirmation command if you want the IDE to close a dialog automatically. In the Kantu implementation of the Selenium IDE this command is not needed, as Kantu closes (presses OK) on appearing dialogs automatically. So in other words, chooseOkOnNextConfirmation is built-in, and not needed as separate command. The reason for this behavior is that in 99% of all automation cases users just want to close dialog boxes and move on.

All that said, let me ask what you want to achieve by using windows.confirm? Do you use it to get input from a user? Or just to pause the execution/debug?

Depending on the goal, I can suggest a workaround.

Thanks for the response. I am looking for input from a user. I have a loop that runs and uses confirm dialogues to branch off to take different actions depending on the user’s input. If they confirm yes, it runs through the script, if they confirm no, it goes to the next record.

do you have a workaround for this use case?

Workaround => Ask for user input with storeEval

But also: We plan to solve the original issue, too.

Hi , is there any new update to this workaround? other than the clipboard method

Yes, good news: We will release an update in few days that has a new PROMPT command:

PROMPT | please enter a value@default value | variable

The input from the user is then stored in the variable.

You can already test it with the Kantu beta version.

1 Like

Hi , glad to hear that ,I’m pretty sure the others too.
I’m trying to lessen the burden for data entry on this website. A prompt would easily make Kantu a dealbreaker for everyone planning to use Automation plugins

It’s available now :smiley:
prompt

1 Like

yes, I’ve already been using it since yesterday.
Thank you guys for the hard work…! I think more people will appreciate this

i’m using kantu to autofill an online form, what if i wanted an alert to display after the macro recording finishes playing?