This is a migrated thread and some comments may be shown as answers.

Click on the control closes alerts which should have been created after clicking this control

11 Answers 87 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
kovyar
Top achievements
Rank 1
kovyar asked on 20 Jul 2010, 03:02 PM
Hello,
I suspect a problem with migrating from WebAii 1.1 to WebAii 2.0.
One of our tests is like this: button should be clicked, then it causes an alert to popup.
After that alert is analyzed and closed.

But after clicking the button the alert is immediately closed without any opportunity to check it up.

The code:
Settings mySettings = new Settings(BrowserType.InternetExplorer, @"c:\log\");
             
Manager myManager = new Manager(mySettings);
myManager.Start();
myManager.LaunchNewBrowser();
myManager.ActiveBrowser.NavigateTo("file:///d:/test.html");
 
Element mybtn = myManager.ActiveBrowser.Find.ByName("press_me");
myManager.Desktop.Mouse.Click(MouseClickType.LeftClick, mybtn.GetRectangle()); //after that the dialog window must appear, but it closes immediately
 
myManager.Dispose();
and the HTML file:
<html>
<head>
<title>Click test.</title>
</head>
<body>
<input type="button" name="press_me" value="press_me" onclick="alert('Hello world!');"/>
</body>
</html>

I have the latest version of WebAii framework (2010.2 713). All the other ways of clicking (eg element.Click()) produce the same output.

Regards,
Yaroslav

11 Answers, 1 is accepted

Sort by
0
Kiran
Top achievements
Rank 2
answered on 20 Jul 2010, 06:23 PM
Hi kovyar,

I tested the same code in my machine with WebAii 2.0. Its working.
Can you uninstall WebAii 1.1 and WebAii 2.0 and try once again installing WebAii 2.0.

Thanks
Kiran
0
kovyar
Top achievements
Rank 1
answered on 21 Jul 2010, 08:14 AM
Hi kiran,
and thanks for the answer.

Now I have only WebAii 2.0 installed on my machine.
Well, the piece of code which I posted before doesn't show the problem, because everything is closed immediately after the click.
The following code should work:

Settings mySettings = new Settings(BrowserType.InternetExplorer, @"c:\log\");
 
Manager myManager = new Manager(mySettings);
myManager.Start();
myManager.LaunchNewBrowser();
myManager.ActiveBrowser.NavigateTo("file:///d:/test.html");
Thread.Sleep(5000);
Element mybtn = myManager.ActiveBrowser.Find.ByName("press_me");
myManager.Desktop.Mouse.Click(MouseClickType.LeftClick, mybtn.GetRectangle()); //after that the dialog window must appear
Thread.Sleep(10000); //only after 10 seconds alert and browser window must disappear
//well, in WebAii 1.1 nothing is closed until I close the alert window
myManager.Dispose();

In fact, the alert window disappears immediately although there is no code which might close it.

Thanks
Yaroslav
0
kovyar
Top achievements
Rank 1
answered on 21 Jul 2010, 09:08 AM
Hi all,
things are even worse than I expected.

As far as I understand, WebAii 2.0 suppresses all the alerts raised during the session.

For example, if I launch the following code:
Settings mySettings = new Settings(BrowserType.FireFox, @"d:\"); //no matter whether it is FF or IE
Manager myManager = new Manager(mySettings);
  
myManager.Start();
myManager.LaunchNewBrowser();
myManager.ActiveBrowser.NavigateTo("file:///d:/test.html");
Thread.Sleep(20000); //this give me time to click the button before Manager closes the browser
myManager.Dispose();

And try to click the button on the page (look post #1), the alert appears for ~0.2 seconds and is being closed by something unknown.


Does anybody know how to fix this?

All the best
Yaroslav
0
Kiran
Top achievements
Rank 2
answered on 21 Jul 2010, 09:09 AM
Hi,

I put the Thread.Sleep and tested. Its working in my machine.
Also if we wont put Thread.Sleep also the appliction wont exist if we open an alert box. Unless and until u close the Alert box the application wont close.

Thanks
Kiran
0
kovyar
Top achievements
Rank 1
answered on 21 Jul 2010, 04:48 PM
HI, thanks a lot for your help.

I think I know what's the problem: WebAii is suppressing "unexpected dialogs".
The problem in our test was solved by setting
Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;

So that I could handle all the appearing dialogs by my own.

Kiran, could you, please, tell me, which value for UnexpectedDialogAction is set when you run the code I've provided.
I suspect we have different values, but unsure.

Thanks
Yaroslav
0
Kiran
Top achievements
Rank 2
answered on 21 Jul 2010, 06:24 PM
Hi Yaroslav,

I am not having UnexpectedDialogAction property in Manager.Settings

Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;

Thanks
Kiran

0
Accepted
Konstantin Petkov
Telerik team
answered on 21 Jul 2010, 09:54 PM
Hi guys,

That settings has been introduced with the latest 2010.2 release of the framework. The default value is HandleAndFailTest so that unexpected dialogs like JavaScript errors will cause the test to fail. As noticed it's configurable so that one can set it to not handle the unexpected dialogs or handle and continue.

Sincerely yours,
Konstantin Petkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Kiran
Top achievements
Rank 2
answered on 22 Jul 2010, 08:36 AM
Hi Petkov,

Ohhh... That is a great feature.
In my project the tests were failing if there is any javascript error in the DOM.
Thanks for the information. I will updated the framework to the latest.

Thanks
Kiran
0
kovyar
Top achievements
Rank 1
answered on 22 Jul 2010, 10:09 AM
Hi, all

and thanks for the clarifying.

Konstantin, could you, please, tell me how the system decides whether the alert is 'unexpected' or not.
I ask this just because we have a test where a dialog must appear and then we handle it, but the system (if DoNotHandle is not set) kills it immediately.

Thanks
Yaroslav
0
Jasper
Telerik team
answered on 22 Jul 2010, 04:25 PM
Hi kovyar,

When you create the Manager object, it implicitly creates a DialogMonitor, and initializes it with the Settings you pass to it.

A dialog is deemed unexpected if it has not been added to the DialogMonitor's list of dialogs to watch for, via the AddDialog method.

I believe simply adding your alert dialog to Manager.DialogMonitor should do the trick.

Regards,
Jasper
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
kovyar
Top achievements
Rank 1
answered on 22 Jul 2010, 05:33 PM
Hi,

and thanks for the answer. Now the things became clearer.

Thanks,
Yaroslav
Tags
General Discussions
Asked by
kovyar
Top achievements
Rank 1
Answers by
Kiran
Top achievements
Rank 2
kovyar
Top achievements
Rank 1
Konstantin Petkov
Telerik team
Jasper
Telerik team
Share this question
or