Anyone know how to click the 'OK' button on a Confirm Function Pop-Up?

dstuart
Kilo Expert

On several of our 'create' UI Actions, like Create Problem and Create Change, we have added a Confirm() function call, to be sure that the user really wants to create a Problem or a Change Request. And the User needs to click 'OK' to create the PRB/CHG/etc., or 'Cancel' to stay on the current form. 

Does anyone know how, in an ATF test step, to click on the 'OK' button on a Confirm function pop-up? 

I've tried a Click on Modal Button, but the Confirm() pop-up apparently doesn't count as a a 'modal' button. And it's not considered a UI action. I can't create a PRB from an INC, or a CHG, either. That's the largest impediment to my creation of ATF tests. Along with the 'New' button on a Related list... 

Thanks, Dave 

14 REPLIES 14

Luis Lobo
Kilo Contributor

I am also facing the same issue, I have a pop-up message that needs to be confirmed before moving forward.   Has anyone figured out a solution to this? Ideally, I want to be able to hit ok and move on.

ServiceNow can you please code some magic so we can test this confirm popup alert box by an ATF test step.

Hi Luis,

When you run your test is the confirm dialog appearing? Alert and Confirmation dialogs should be handled by the Client Test Runner according to the documentation here https://docs.servicenow.com/bundle/orlando-application-development/page/administer/auto-test-framewo...

Javascript window command intercepts

The Client Test Runner captures
 window object commands including console.log, console.error, alert, confirm, and prompt, with
 default responses where necessary.

  • Any script that calls window.confirm receives a
 boolean response of true.
  • Any script that calls window.prompt receives the
 string response test value.

We have some alert and confirmation messages that appear when we manually perform an action, but these messages do not appear in ATF.

Hope this helps.

Thanks,

Cody

Luis Lobo
Kilo Contributor

Yes the confirm dialog message does appear, when I run the ATF test but adding a step to click on the  "OK" button so I can move forward with my flow is where I'm stuck.

As test steps "Click on Modal Button, Click a UI action and Click on Component (Custom UI)" doesn't seem to do the trick either. 

codycotulla
Tera Guru

Hi Luis, is the confirmation message that you are using a ServiceNow dialog? Like the one that appears when you try to delete a record?

find_real_file.png

Or is it a browser dialog like this?
find_real_file.png

Thanks,

Cody

 

Hi Cody,

My dialog message is  the same as your 2nd screenshot(browser dialog)