Friday, March 2, 2012

Session Data loss popup problem

I want to share one of my experiences in how easy to maintain scripts when we follow Page Object pattern with a recent change in one of the application.

To avoid data loss while navigating or refreshing to a page, a popup window appears with message "Application session / Data will be loss" with OK and Cancel button. (And which is not a JavaScript popup :( )
Problem:

There are too many flows where the application opens dialog boxes, frames, popup etc.
Everywhere we need to handle the Session popup.

Solution: When we view the source code of the page, we got to know the JavaScript for Session popup written as below

&lt script language="JavaScript" &gt

var allowPrompt = true;

window.onbeforeunload = confirmExit;
.....
So, to avoid this we used  ”this.browserbot.getCurrentWindow().allowPrompt=false"  command in our base page constructor which solved the problem.
Now we are happily running our tests without any change in our test script(s).

No comments: