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

12 posts, 1 answers
  1. kovyar
    kovyar avatar
    42 posts
    Member since:
    Jul 2010

    Posted 20 Jul 2010 Link to this post

    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
  2. Kiran
    Kiran avatar
    56 posts
    Member since:
    Dec 2008

    Posted 20 Jul 2010 Link to this post

    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
  3. kovyar
    kovyar avatar
    42 posts
    Member since:
    Jul 2010

    Posted 21 Jul 2010 Link to this post

    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
  4. kovyar
    kovyar avatar
    42 posts
    Member since:
    Jul 2010

    Posted 21 Jul 2010 Link to this post

    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
  5. Kiran
    Kiran avatar
    56 posts
    Member since:
    Dec 2008

    Posted 21 Jul 2010 Link to this post

    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
  6. kovyar
    kovyar avatar
    42 posts
    Member since:
    Jul 2010

    Posted 21 Jul 2010 Link to this post

    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
  7. Kiran
    Kiran avatar
    56 posts
    Member since:
    Dec 2008

    Posted 21 Jul 2010 Link to this post

    Hi Yaroslav,

    I am not having UnexpectedDialogAction property in Manager.Settings

    Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;

    Thanks
    Kiran

  8. Answer
    Konstantin Petkov
    Admin
    Konstantin Petkov avatar
    1911 posts

    Posted 21 Jul 2010 Link to this post

    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
  9. Kiran
    Kiran avatar
    56 posts
    Member since:
    Dec 2008

    Posted 22 Jul 2010 Link to this post

    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
  10. kovyar
    kovyar avatar
    42 posts
    Member since:
    Jul 2010

    Posted 22 Jul 2010 Link to this post

    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
  11. Jasper
    Admin
    Jasper avatar
    5 posts

    Posted 22 Jul 2010 Link to this post

    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
  12. kovyar
    kovyar avatar
    42 posts
    Member since:
    Jul 2010

    Posted 22 Jul 2010 Link to this post

    Hi,

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

    Thanks,
    Yaroslav
Back to Top