chooseCancelOnNextConfirmation, chooseOkOnNextConfirmation

717 views
Skip to first unread message

dipanshumansingka

unread,
Jul 8, 2008, 8:00:46 AM7/8/08
to selenium-users...@googlegroups.com
Can these methodsbe used only with IDE?

Any sample applicaiton on how it can be used with RC

Will it pass the event to the pop ups / dialogs displayed.

I had opened a preference tab of my email application.

did some changes and then tried to move to other tab by running the following script in IDE.

<tr>\\ <td>chooseCancelOnNextConfirmation</td>\\ <td></td>\\ <td></td>\\ </tr>\\ <tr>\\ <td>open</td>\\ <td>[http://XXXXXXXXXXXXXXXXXX</td>|http://xxxxxxxxxxxxxxxxxx%3c/td%3E]\\ <td></td>\\ </tr>\\ <tr>\\ <td>chooseCancelOnNextConfirmation</td>\\ <td></td>\\ <td></td>\\ </tr>

Whether using chooseCancelOnNextConfirmation before or after trying to move to other page was not able to return false and close the confirmation dialog.

Below thing is also not working for me

<tr>\\ <td>chooseCancelOnNextConfirmation</td>\\ <td></td>\\ <td></td>\\ </tr>\\ <tr>\\ <td>click</td>\\ <td>ctl_checkbox1</td>\\ <td></td>\\ </tr>\\ <tr>\\ <td>assertConfirmation</td>\\ <td>Are you sure?</td>\\ <td></td>\\ </tr>\\ .......

dipanshumansingka

unread,
Jul 9, 2008, 1:49:24 AM7/9/08
to selenium-users...@googlegroups.com
Thanks for the reply.



I get the following error

* [/info] Executing: |chooseCancelOnNextConfirmation | | |
* [/info] Executing: |click | clientA | |
* [/info] Executing: |click | //a[@id='TAB_MAIL']/span[2] | |
* [/info] Executing: |assertNotConfirmation | Are you sure you want to
navigate away from this page? | |
* [/error] There were no confirmations
Thanks,
Dipanshu.

Todor Tukov

unread,
Jul 9, 2008, 5:53:46 AM7/9/08
to selenium-users...@googlegroups.com
Hi,

I'm not exactly sure what the issue is but here are a couple of notes.

1. chooseCancelOnNextConfirmation and chooseOkOnNextConfirmation can be used both in Selenium IDE and Seleinium RC and should work.
2. As you probably know, these two are just flags. This means that every time you expect a confirmation to be shown you should use either chooseCancelOnNextConfirmation or chooseOkOnNextConfirmation before the action that triggers the confirmation.
3. When using these flags you should also use one of the following assertConfirmation, verifyConfirmation, or waitForConfirmation. Ideally, you should use waitForConfirmation supplying the text of the confirmation in the "target" parameter of the command.
4. assertNotConfirmation checks whether there was a confirmation but the confirmation text is not the one that you supplied in the "target" parameter of the command. Regarding you last post, the command failed, as the output itself says, because there were no confirmation. Most likely this is due to the fact that the script executed very fast and the assertNotConfirmation command failed to catch the confirmation. You could try replacing assertNotConfirmation with waitForNotConfirmation. In my opinion when you write scripts you should either check whether a confirmation with specific text is displayed or no confirmation is displayed at all. But if you use assertNotConfirmation obviously you need to do it :)

Regards

dipanshumansingka

unread,
Jul 9, 2008, 6:48:22 AM7/9/08
to selenium-users...@googlegroups.com
Thank you.

I also tried with waitForNotConfirmation. Now I am getting the error:

[error] Timed out after 30000ms

<tr>\\ <td>chooseCancelOnNextConfirmation</td>\\ <td></td>\\ <td></td>\\ </tr>\\ <tr>\\ <td>click</td>\\ <td>clientA</td>\\ <td></td>\\ </tr>\\ <tr>\\ <td>click</td>\\ <td>//a[@id='TAB_MAIL']/span[2]</td>\\ <td></td>\\ </tr>\\ <tr>\\ <td>waitForConfirmation</td>\\ <td>Are you sure you want to navigate away from this page?<br />Your changes are not saved.<br />Press OK to continue, or Cancel to stay on the current page.</td>\\ <td></td>\\ </tr>

Is this is the issue.

NOTE: under Selenium, JavaScript confirmations will NOT pop up a visible dialog.

NOTE: Selenium does NOT support JavaScript confirmations that are generated in a page's onload() event handler. In this case a visible dialog WILL be generated and Selenium will hang until you manually click OK.

Todor Tukov

unread,
Jul 9, 2008, 7:07:33 AM7/9/08
to selenium-users...@googlegroups.com
Hi,

What do you use the <br/> in the confirmation text for? New line?

If the confirmation text is spred on multiple lines use /n instead of <br/>

dipanshumansingka

unread,
Jul 9, 2008, 8:34:21 AM7/9/08
to selenium-users...@googlegroups.com
It's a standard confimation dialog which firefox popups up.

On IDE in table tab if I specify the target as

Are you sure you want to navigate away from this page?\nYour changes are not saved.\nPress OK to continue, or Cancel to stay on the current page.

In source tab it converts it to

<td>Are you sure you want to navigate away from this page?<br />Your changes are not saved.<br />Press OK to continue, or Cancel to stay on the current page.</td>

////////////////////////

If in source I specify as

<td>Are you sure you want to navigate away from this page?\nYour changes are not saved.\nPress OK to continue, or Cancel to stay on the current page.</td>

It will read the text as

[info] Executing: |waitForConfirmation | Are you sure you want to navigate away from this page?\nYour changes are not saved.\nPress OK to continue, or Cancel to stay on the current page. | |

////////////

In first case it will correctly read it as

[info] Executing: |waitForConfirmation | Are you sure you want to navigate away from this page? Your changes are not saved. Press OK to continue, or Cancel to stay on the current page. | |

Since the confirmation dialog shows a line space between the two lines. I also tried with

<td>Are you sure you want to navigate away from this page?*<br />Y<br />*our changes are not saved.*<br /><br />*Press OK to continue, or Cancel to stay on the current page.</td>

But it does not work.

If I write it as

<td>Are you sure you want to navigate away from this page?\n\nYour changes are not saved.\n\nPress OK to continue, or Cancel to stay on the current page.</td>

it will read the string as

[info] Executing: |waitForConfirmation | Are you sure you want to navigate away from this page?\n\nYour changes are not saved.\n\nPress OK to continue, or Cancel to stay on the current page. | |

Reply all
Reply to author
Forward
0 new messages