Firefox not waiting on submit?

5 posts, 0 answers
  1. Kendall Bennett
    Kendall Bennett avatar
    80 posts
    Member since:
    Feb 2010

    Posted 27 May 2013 Link to this post

    I am playing with the Telerik Testing Framework to compare it to Selenium, so we can decide if we will use it or Selenium moving forward. So far it seems to work well, and I have my first simple test case working great with IE. However when I run it with Firefox it fails, because when I submit the form on a page it returns immediately to my test code, while Firefox is still processing the submit in the background. With IE it does not do this, and waits until the submit has finished, and the site has rendered the resulting next page (which is the result of a redirect; it is testing our login page).

    The code for the simple test is as follows:

    // Browse to the login page
     
    // Enter the user name and password
    Find.ById<HtmlInputText>("UserName").Text = "UserName";
    Find.ById<HtmlInputPassword>("Password").Text = _strongPassword;
     
    // Now submit the form
    Find.ByAttributes<HtmlInputSubmit>("value=Confirm").Click();
     
    // Make sure we ended up on the categories page and the login succeeded
    Assert.IsTrue(Browser.ContainsText("Categories / Products"));

    The problem crops up with the Assert at the end. With IE, the test framework waits when the .Click() is done on the confirm button, and does not return until the resulting page has rendered. So then I can test for the content and it woks. With Firefox it returns immediately and the content in the browser is not correct since it has not yet changed, but the submit is being processed in the background.

    I was trying to find out if there is a way to force it to wait after the submit to make it work with Firefox, but can't figure that out yet. But either way I think the test framework should be waiting on submit until the browser has settled and rendered the next page?
  2. Kendall Bennett
    Kendall Bennett avatar
    80 posts
    Member since:
    Feb 2010

    Posted 27 May 2013 Link to this post

    Hmm, I am using RoboForm for password management. I wonder if this is messing things up? One thing that is different between Selenium and the Telerik tools when using Firefox is that Selenium starts up Firefox using a totally clean profile. So none of the add ins etc are there, to potentially mess stuff up. Is there a way to load Firefox with a clean profile when using the Telerik tools?

    In fact that would be preferable with IE also to avoid any similar issues with Roboform in IE.
  3. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 28 May 2013 Link to this post

    Hi Kendall,

    After performing a mouse click you may need to explicitly wait  for the browser to be ready. Please try to add ActiveBrowser.WaitUntilReady(); after the click step. For more information please see this page.

    You can also wait on a specific known element to appear: yourElement.Wait.ForExists(30000). This means that using this code the execution will wait up to the time set(30 seconds in this case), refreshing the DOM tree on every 500 ms, and when the element is found will proceed with the line of code.

    As a last resort you can use fixed delay: System.Threading.Thread.Sleep(5000);

    We have a known issue with RoboForm, but it is connected with Dailog Handling. However you can try to disable/uninstall it and give it a try.

    Hope this helps.

    Regards,
    Boyan Boev
    Telerik
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  4. Kendall Bennett
    Kendall Bennett avatar
    80 posts
    Member since:
    Feb 2010

    Posted 28 May 2013 Link to this post

    Well the BrowserReady function just returned immediately also. I wrote this code based on the sample test that is created when you add a new test to your project using Visual Studio, as it does the same thing. That test, if you run it with Firefox, will also fail for the same reason. It returns immediately when the .Click() function is called for a submit button.

    The solution I came up with for the time being was to wait until the destination URL I am expecting shows up, and then it works. Also I don't think RoboForm is causing this problem.

    BTW, to avoid issues with any plugins like RoboForm or others that might cause problems, it would be worth considering doing what Selenium does when it spawns Firefox. It uses the -profile command line option to spawn the Firefox used for testing with a completely fresh profile (and you can force a specific one if you wish). That way you know it won't get messed up by any other features or plugins. It would be really good if the Telerik tools could do the same thing:

    firefox.exe -profile "E:\myprofile"

    I also believe if you do this, it will spawn a brand new Firefox instance, so it won't interfere with an existing one that you might have running at the same time.
  5. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 31 May 2013 Link to this post

    Hi Kendall,

    I am glad to hear you have found a solution.

    Thank you for your suggestion also. We have created an entry into our public Feedback Portal in the form of a feature request (see public link).

    Let me know if you need further assistance.

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