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

[Solved] ArtOfTest fails unless I single step in debug mode

2 Answers 122 Views
ASP.NET AJAX WebAii RadControls
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
woaksie
Top achievements
Rank 2
woaksie asked on 19 Oct 2009, 07:33 PM
I have a number of Editors on a page. I have an automated test that clicks the image button on one of the editors. This is a custom dialog that is a page with two frames. I am trying to get a reference to both frames so I can manipulate the contents. The following code works if I single step through in debug mode but fails if I just run it. I commented the line that fails. This is my version of the example code found in the documentation.

      var frameCount = 2;
      switch (ActiveBrowser.BrowserType)
      {
        case BrowserType.FireFox:
        case BrowserType.InternetExplorer:
          frameCount = 6;
          break;
        case BrowserType.Safari:
          break;
      }

      Wait.For(mybrowser => mybrowser.Frames.Count == frameCount, ActiveBrowser, 12000);

      var result = new List<HtmlForm>(2);

      FramesCollection frames = ActiveBrowser.Frames;

      Browser topFrame = frames[1];

      Wait.For(mybrowser => mybrowser.Find.SearchRootElement.Children.Count > 1, topFrame, 12000);

      var kids = topFrame.Find.SearchRootElement.Children;
      var firstKid = kids[1];
      var kidsKids = firstKid.Children;

      result.Add(kidsKids[0].As<HtmlForm>());

      var bottomFrame = frames[2];

    // ***** This line times out when I run this code but not if I single step in debug mode.
      Wait.For(mybrowser => mybrowser.Find.SearchRootElement.Children.Count > 1, bottomFrame, 12000);

    // ***** If I remove the above line the kids[1] fails with index out of range
      kids = bottomFrame.Find.SearchRootElement.Children;
      firstKid = kids[1];
      kidsKids = firstKid.Children;

      result.Add(kidsKids[0].As<HtmlForm>());

      return result;


************ an update ********************

I put in some Thread.Sleep(4000); statements and the test now works. Not an ideal solution so still looking for the correct way to get this working.

2 Answers, 1 is accepted

Sort by
0
Petko
Telerik team
answered on 22 Oct 2009, 06:15 AM
Hello John,

I tried to reproduce your issue and ran the test under Safari, but the test passed no matter I debugged or ran it. You can use Thread.Sleep() as alternative of  WaitFor() or to refresh DOM tree before the problematic WaitFor with the following line:
ActiveBrowser.RefreshDomTree();
If this does not help you, please send more detailed information about your test case: which browser you have used, does bigger timeout in WaitFors help you? Can you also send us your complete test and testing page?

All the best,
Petko
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
woaksie
Top achievements
Rank 2
answered on 22 Oct 2009, 08:40 PM
ActiveBrowser.RefreshDomTree(); 

The RefreshDomTree() does not make any difference. A Thread.Sleep() causes the test to succeed.

      Thread.Sleep(new TimeSpan(0, 0, 2)); 
      Wait.For(mybrowser => mybrowser.Frames.Count == frameCount, ActiveBrowser, 12000); 

Tags
ASP.NET AJAX WebAii RadControls
Asked by
woaksie
Top achievements
Rank 2
Answers by
Petko
Telerik team
woaksie
Top achievements
Rank 2
Share this question
or