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

@cody 
Here is a better screenshot.


Thanks!

codycotulla
Tera Guru

Hi Luis, 

Maybe it isn't relevant, but I see that the dialog says that it is from 'servicenowservices.com' It looks like it is a windows confirm message.

What is the step that you run before that?

codycotulla
Tera Guru

Hi Luis,

I am probably spending way more time trying to figure this out than I should be. That said, I've got a few more ideas.

It looks like the Client Test runner overloads (hope that's the right term) the window alert() and confirm() methods, so that if an alert() or confirm() are called, the overloaded function handles the call and prevents the blocking dialog from appearing. In the case of an alert() function call, nothing happens. In the case of a confirm() function call true is just returned. In both cases no dialog is shown and so the automated test isn't blocked.

So, I'd like a little more information on your specific situation.

1) Can you provide the code you are using to create the alert message? I assume, your just using confirm("message"), but I'd still like to see it--minus any proprietary stuff, of course. 🙂

2) What is the form or list from which you are presenting the confirm message?

3) How is the confirm message being triggered? By a UI action or on submit or what?

4) What release of ServiceNow are you on?

The Client Test runner happens to be something I am digging into right now, so your question is giving me a challenge that's helping me to learn more. I'd like to help you get the problem solved, though. It's be great if my "nerding out" helped someone other than me.

Look forward to hearing back from you.

Thanks,

Cody

Morning Cody, 

I this 'override' of the alert() and confirm() functions new behavior? My experience is that when a confirm() function pop-up came up, ATF would just stop, as it didn't know what to do with it. Granted, I haven't tested it for a while. 

The confirm() function code that we use is below. It was originally published on the SN Guru site, and we've modified it slightly for our specific cases. 

 

Dave 

 

 

 

function confirmSreq() {
var sreqNumber = g_form.getValue('number');

var answer = confirm("Are you sure you want to create a Change Request from " + sreqNumber + "?");

if (answer == false) {
return false;
}

// call the UI Action and skip the 'onClick' function

gsftSubmit(null, g_form.getFormElement(), 'create_chg_from_sreq');
}


// code that runs without 'onClick'
// ensure call to server-side function with no browser errors

if (typeof window == 'undefined') {
createChgFromSreq();
}


// create the Change Request

function createChgFromSreq() {

codycotulla
Tera Guru

Hi Dave, Luis,

 

I was able to reproduce the problem. The issue has to do with the page reloading. If you have a Click UI Action step that submits the page, and has an Assertion type of --None--, and then you later have a Click UI Action step that calls a function with an alert() or confirm() message in it, the confirm() or alert() message appears.

So to address the problem, make sure that on your Click a UI Action steps, the Assertion type is set to something other than --None--

Let me know if you have any questions and if this addresses the issue your having (or were having a couple years ago).

Thanks,

Cody