FireFox Alerts

11 posts, 0 answers
  1. Matt
    Matt avatar
    19 posts
    Member since:
    Dec 2013

    Posted 21 Mar 2014 Link to this post

    Hello,

    I created some code that handles a Confirmation (OK / CANCEL) and an Alert (OK) in IE and Chrome.

    However, running in FireFox it just hangs on the alerts. 

    Any suggestion for how to handle the alerts in FireFox?

    Thanks,
    Matt
  2. Velin Koychev
    Admin
    Velin Koychev avatar
    88 posts

    Posted 26 Mar 2014 Link to this post

    Hello Matt,

    I am sorry to hear that  you are experiencing this issue.
     
    Please provide us with a copy of your test and if it is possible grant us access to your application so we can reproduce the issue on our end and give you a solution. 

    If direct access is not possible, capture a Fiddler trace and attach it to this support ticket in a zip file. If you are unfamiliar with how to do so, this link will provide you with step-by-step instructions for download and use. If taking a Fiddler trace please be sure to:
    1. Click Clear Cache first
    2. Check Store binaries
    3. Check Decrypt HTTPS traffic

    Hope to hear from you soon.

    Regards,
    Velin Koychev
    Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
  3. Matt
    Matt avatar
    19 posts
    Member since:
    Dec 2013

    Posted 26 Mar 2014 in reply to Velin Koychev Link to this post

    Hi Velin,

    Unfortunately, I am neither going to be able to provide you access to the application or provide a Fiddler trace.

    I will provide code though.

    In summary, this is the flow of the application: Upon initial load of a page a JS alert will pop with the option to hit [OK], the page is not allowed to finish loading until the alert has been dismissed. I get a nullReference exception on dialog.window when using FireFox. 

    The following is how our alert handler is set up.

    01./// <summary>
    02./// Sets up dialog handler and starts the dialog monitor
    03./// </summary>
    04.public void startMonitoringAlertDialog() {
    05.    // our new dialog monitor and start it
    06.    _dialog = AlertDialog.CreateAlertDialog(_activeBrowser, DialogButton.OK);
    07.    _dialog.HandlerDelegate = customAlertHandler;
    08.    _manager.DialogMonitor.AddDialog(_dialog);
    09.    _manager.DialogMonitor.Start();
    10.}
    11. 
    12./// <summary>
    13./// Handler for alerts
    14./// </summary>
    15./// <param name="dialog"></param>
    16.private void customAlertHandler(IDialog dialog) {
    17.    string txt = dialog.Window.AllChildren[dialog.Window.AllChildren.Count - 1].Caption;
    18.    determineIfDialogContainsExpectedMessage(txt);
    19.    dialog.HandleCount++;
    20.}
    21. 
    22./// <summary>
    23./// Sets _actualTextMatchedExpected to true if the _expectedText was found
    24./// in the dialog caption
    25./// </summary>
    26./// <param name="dialogText"></param>
    27.private void determineIfDialogContainsExpectedMessage(string dialogText) {
    28.    if (string.IsNullOrEmpty(_expectedText))
    29.        return;
    30.    if (dialogText != null && dialogText.Contains(_expectedText)) {
    31.        _actualTextMatchedExpected = true;
    32.    } else {
    33.        _actualTextMatchedExpected = false;
    34.    }
    35.}
    36. 
    37.public MyAlertDialog getAlertDialogWithExpectedText(string expectedWarningMessage) {
    38.    MyAlertDialog alertDialog = new MyAlertDialog(browser.aiiBrowser, browser.aiiBrowser.Manager);
    39.    alertDialog.setExpectedWarningDialogText(expectedWarningMessage);
    40.    alertDialog.startMonitoringAlertDialog();
    41.    return alertDialog;
    42.}
    43. 
    44./// <summary>
    45./// Public getter for _actualTextMatchedExpected,
    46./// Indicates whether or not expected text was found
    47./// </summary>
    48./// <returns></returns>
    49.public bool matchedExpectedText() {
    50.    return _actualTextMatchedExpected;
    51.}
    52. 
    53.[TestMethod]
    54.public void alertIsDisplayedWhenNavigatingToPage() {
    55.    // Arrange
    56.    const string EXPECTED_MESSAGE = "Welcome.";
    57.    MyAlertDialog dialog = getAlertDialogWithExpectedText(EXPECTED_MESSAGE);
    58. 
    59.    //Act
    60.    browser.navigateTo(url);
    61. 
    62.    // Assert
    63.    Assert.AreEqual(1, dialog.getNumberOfDialogsHandled(), "The warning dialog is not displayed when going to the page.");
    64.    Assert.IsTrue(dialog.matchedExpectedText(), "The warning dialog did not match the expected text when going to the page.");
    65.}
  4. Velin Koychev
    Admin
    Velin Koychev avatar
    88 posts

    Posted 31 Mar 2014 Link to this post

    Hello Matt,

    Thank you for sharing the code.

    Unfortunately I am having some issues reproducing the problem. 

    Can you please try to reproduce it against a public website like this one or another one. 
    Could you please also share the whole test files, because some parts of the code are missing and I had to make some changes in the code. 

    Thank you for your cooperation.
     
    Regards,
    Velin Koychev
    Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
  5. Matt
    Matt avatar
    19 posts
    Member since:
    Dec 2013

    Posted 31 Mar 2014 Link to this post

    Hi Velin,

    I attempted to run a test using the website you provided. After doing so, now I cannot get Chrome to dismiss the alert as well. However, it works fine in IE 10.

    I'm using the following versions:
    TTF 2013.2 1327
         ArtOfTest.WebAii.dll
         Telerik.WebAii.Controls.Html.dll

    Internet Explorer 10.0.14 (KB2925418)
    FireFox 29.0 (Beta update channel)
    Chrome 33.0.1750.154 m

    Here is the code for this test:
    01.[TestMethod]
    02.        public void testAlertOnFireFox() {
    03.            AlertDialog dialog = new AlertDialog(ActiveBrowser, DialogButton.OK);
    04.            Manager.DialogMonitor.AddDialog(dialog);
    05.            Manager.DialogMonitor.Start();
    06.            browser.navigateTo("http://www.w3schools.com/js/tryit.asp?filename=tryjs_alert");
    07.            HtmlButton tryIt = null;
    08.            int timer = 0;
    09.            while (tryIt == null && timer < 10000) {
    10.                tryIt = browser.aiiBrowser.Frames["view"].Find.ByContent<HtmlButton>("l:Try it");
    11.                System.Threading.Thread.Sleep(15);
    12.                timer += 15;
    13.                browser.refreshDomTree();
    14.            }
    15. 
    16.            tryIt.MouseClick();
    17. 
    18.        }
  6. Matt
    Matt avatar
    19 posts
    Member since:
    Dec 2013

    Posted 31 Mar 2014 Link to this post

    Correction, using the previous code I just provided, the alert on that page is not being dismissed in any browser.
  7. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 03 Apr 2014 Link to this post

    Hi Matt,

    I had to modify your code to be compatible as a Visual Studio unit test using our framework. After doing so it's working perfectly here:
    http://screencast.com/t/EDvXngqm83Y

    If you want to send us a complete Visual Studio project we can load and run here we'll be happy to have another look at this. Perhaps there's a problem with your test initialization code.

    Regards,
    Cody
    Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
  8. Matt
    Matt avatar
    19 posts
    Member since:
    Dec 2013

    Posted 03 Apr 2014 Link to this post

    Thanks Cory for the reply.

    I have been able to further debug our testing code and found what we believe was the cause of the browser hanging on the JavaScript Alerts. So yay for that.

    Now, I guess the easiest way for me to do this is to simply ask, what is the best way to get the message that is being displayed on a Javascript Alert. So for one that says "Welcome.", how can I get the text so that I can verify "Welcome." was said?

    Our issue stemmed from complications in creating a customAlertHandler that tried to do just that and ended up crashing WebAii or trying using the window when the window was set to Null.

    So this alters my original query then, but I don't feel it's best to create a new topic for that. If you'd like to rename the thread to address my actual issue, by all means.

    Thanks for everything,
    Matt
  9. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 03 Apr 2014 Link to this post

    Hi,

    We have this code sample that demonstrates how to grab the text from a popup dialog. It was intended to be used in a coded step of Test Studio, but it should not be difficult to adapt it to a framework only test.

    Regards,
    Cody
    Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
  10. Matt
    Matt avatar
    19 posts
    Member since:
    Dec 2013

    Posted 04 Apr 2014 Link to this post

    Hi Cody,

    Unfortunately that didn't help me much.

    I am still unable to grab the error text message.

    Using the prior code you provided, could you share with me the code necessary to do so on FireFox?

    My previous custom handler delegate is still failing with my original code, and I've attempted to add the 

    string txt =
    dialog.Window.AllChildren[dialog.Window.AllChildren.Count - 1].Caption

    which was previously missing in our custom alert. However, in our custom alert we are getting the same error where "Window = null".in FireFox but not in IE.

    Any help would be appreciated,
    Matt


  11. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 04 Apr 2014 Link to this post

    Hi Matt,

    I am sorry I should have recognized you're trying to do this with Firefox. I'm afraid this is not possible.

    Regards,
    Cody
    Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
Back to Top