When testing, 2 windows appear.
my code is:
string BaseWindow = driver.CurrentWindowHandle;
ReadOnlyCollection<string> handles = driver.WindowHandles;
foreach(string handle in handles)
{
Boolean a = driver.SwitchTo().Window(handle).Url.Contains("Main");
if (a == true)
{
InitialSetting.driver.SwitchTo().Window(handle);
break;
}
}
I want to switch to a window whose URL contains "Main". But when the test runs, it continuously switches between the two windows and does not stop.
I debugged and found that I foreachhad not broken even when I was boolean afaithful.
How can I solve this?
source
share