0

I am using Coded UI (C# language) for recording and playing back a series of events. In it, there's a plus sign which on clicking opens another IE window. I've now to do certain actions on this new browsing window.

Obviously, I did record these steps and it has been generated as code in my script but while playing back, this new window refreshes itself a couple of times and it loses focus I guess. Hence, CUIT is unable to Search the first step that was to be executed on the new window. Could you guys please help me in out here? As in how do I change my script to bring back focus on this new window.

The error as you would've guessed reads:

Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: The playback failed to find the control with the given search properties..

Turnerj
  • 4,258
  • 5
  • 35
  • 52
rjt
  • 27
  • 1
  • 6
  • The "refresh" part of your question suggests that answers to this question may help, see http://stackoverflow.com/questions/27526163/control-exists-within-a-loop-works-for-first-time-and-not-for-second-time-in-c – AdrianHHH Aug 13 '15 at 07:03
  • @AdrianHHH no, not able to relate the two. Could you help me provide more info here? – rjt Aug 13 '15 at 08:36
  • Looking at my answer on the linked page, the `top` control might be your browser and the `middle` control the tab that (in your words) "*refreshes itself a couple of times*". Hence the linked answer suggests calling `Find()` on the UI Control for the browser tab. If that does not work then call it on the UI Control for the browser itself. – AdrianHHH Aug 13 '15 at 09:11

1 Answers1

1

Depending on whether your parent and child windows have the same title you could do the following:

IF both your windows have the same title

You could use Sendkeys to bring back focus to your child/parent window.

  Keyboard.SendKeys("^{TAB}");

So if you're on your child page and need to get back to the parent, make sure you focus on the window you're on first(child) and then use the Sendkeys tab to go to the window you want - else Sendkeys wont work as you want them to.

IF your parent and child have a different title

You could use the BrowserWindow.Locate to bring back focus to your parent/child window.

BrowserWindow.Locate("ParentTabTitle");
Anu7
  • 77
  • 1
  • 17