Running javascript using StoreEval


#1

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”
}
]
}


#2

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


#3

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.


Ask for user input with storeEval
#4

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.


#5

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.


#6

do you have a workaround for this use case?


#7

Workaround => Ask for user input with storeEval

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