Hi All,
In our application, we have a dialog which pops up when a user tries to close the browser without logging out using the official link. We seems to have no control over it and you can't see this in DOm. It just locks the browser control and give you two options :
Leave this Page
Stay on this page
how should I go about handling this use-case, if suppose I intend to click on "Leave this Page"
Thanks in advance!
In our application, we have a dialog which pops up when a user tries to close the browser without logging out using the official link. We seems to have no control over it and you can't see this in DOm. It just locks the browser control and give you two options :
Leave this Page
Stay on this page
how should I go about handling this use-case, if suppose I intend to click on "Leave this Page"
Thanks in advance!
4 Answers, 1 is accepted
0
Hello Aakash,
Thank you for your question.
This type of dialog is considered to be an OnBeforeUnload event (public example site).
You will first need to add a using statement for 'ArtOfTest.WebAii.Win32.Dialogs'.
Please see code sample below which works against the public site mentioned above:
Please let me know whether you have any additional questions.
Regards,
Mario
Telerik
Thank you for your question.
This type of dialog is considered to be an OnBeforeUnload event (public example site).
You will first need to add a using statement for 'ArtOfTest.WebAii.Win32.Dialogs'.
Please see code sample below which works against the public site mentioned above:
OnBeforeUnloadDialog dialog = OnBeforeUnloadDialog.CreateOnBeforeUnloadDialog(ActiveBrowser, DialogButton.OK);
Manager.DialogMonitor.AddDialog(dialog);
ActiveBrowser.NavigateTo(
"http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/onbeforeunload.htm"
);
HtmlAnchor link = Find.ByExpression<HtmlAnchor>(
"innertext=Click here to navigate to www.microsoft.com."
);
link.MouseClick();
dialog.WaitUntilHandled(10000);
Please let me know whether you have any additional questions.
Regards,
Mario
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Test Studio Trainings
0
Chunks
Top achievements
Rank 1
answered on 18 Jun 2013, 09:14 PM
This works, Thank you, Mario!!
0
James
Top achievements
Rank 1
answered on 09 Oct 2013, 05:55 AM
Hi Mario,
We are Telerik's customer for last 4 years and use Rad Controls in our web application. We also use WebAii's testing framework for test automation.
When automated test case load application in the browser and then attempt to close the browser after completing test, browser shows dialog with 2 options "Leave this page" and "Stay on this page".
I want automated test case to choose "Leave this page" option.
I use below code, however it does not seem to choose "Leave this page" and close the active browser.
Could you please advice me how to handle this dialog and choose "Leave this page" to close the active browser?
We are Telerik's customer for last 4 years and use Rad Controls in our web application. We also use WebAii's testing framework for test automation.
When automated test case load application in the browser and then attempt to close the browser after completing test, browser shows dialog with 2 options "Leave this page" and "Stay on this page".
I want automated test case to choose "Leave this page" option.
I use below code, however it does not seem to choose "Leave this page" and close the active browser.
OnBeforeUnloadDialog dialog = OnBeforeUnloadDialog.CreateOnBeforeUnloadDialog(ActiveBrowser, DialogButton.OK);
Manager.DialogMonitor.AddDialog(dialog);
Manager.DialogMonitor.Start();
ActiveBrowser.Close();
dialog.WaitUntilHandled(10000);
Could you please advice me how to handle this dialog and choose "Leave this page" to close the active browser?
0
Hello James,
Hope this helps. Regards,
Ivaylo
Telerik
Please let me interject into this ticket since Mario is out of the office today.
Could you please try placing the following code where this dialog appears:
this
.Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.HandleAndContinue;
Hope this helps. Regards,
Ivaylo
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Test Studio Trainings