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

Firefox not waiting on submit?

4 Answers 84 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kendall Bennett
Top achievements
Rank 2
Kendall Bennett asked on 27 May 2013, 09:51 PM
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?

4 Answers, 1 is accepted

Sort by
0
Kendall Bennett
Top achievements
Rank 2
answered on 27 May 2013, 09:54 PM
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.
0
Boyan Boev
Telerik team
answered on 28 May 2013, 06:59 AM
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
0
Kendall Bennett
Top achievements
Rank 2
answered on 28 May 2013, 05:52 PM
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.
0
Boyan Boev
Telerik team
answered on 31 May 2013, 08:06 AM
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
Tags
General Discussions
Asked by
Kendall Bennett
Top achievements
Rank 2
Answers by
Kendall Bennett
Top achievements
Rank 2
Boyan Boev
Telerik team
Share this question
or