I've been attempting to figure this out for the past two days, unfortunately with no luck. I'm currently automating a scenario where a new window for a form is popped up from the main application under test. Unfortunately, the page with the originating link, and the popup page has the same title.
The code that I'm currently using looks as follows:
string MainWindowHandle = browser.GetWindowHandle();
browser.Click();
ReadOnlyCollection<string> handles = browser.GetWindowHandles();
string newWindowHandle = string.Empty;
foreach (string handle in handles)
{
if(handle != mainWindowHandle)
{
newWindowHandle handle.ToString();
break;
}
}
browser.SwitchTo().Window(newWindowHandle);
Is there another way that I should be doing this, or am I going to need to discuss the possibility of having one of the titles changed by a character?