How do I make selenium webdriver switch between open windows?

1

I need to make the webdriver navigate between open windows. I've tried: this.chromeDriver.SwitchTo().Window(chromeDriver.WindowHandles.Last()); but I can not use Last ().

Is there any missing?

    
asked by anonymous 22.08.2016 / 16:35

2 answers

2

Try to include:

using System.Linq;
    
23.08.2016 / 22:48
0

Try to identify the window you need using:

foreach (var handle in driver.WindowHandles)
{
   driver.SwitchTo().Window(handle);
}

After discovering the window, you can arrive at it like this:

driver.SwitchTo().Window(driver.WindowHandles[1]);
    
12.01.2017 / 20:06