How do I switch between open windows?

Asked

Viewed 4,524 times

1

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

inserir a descrição da imagem aqui

Are you missing any using?

2 answers

2


Try to include:

using System.Linq;
  • It worked for Last() to be accepted, but when I went around the application, it didn’t change the windows, it just went to the next instruction that I was looking for an element in the other window and didn’t find.

0

Try to identify the window you need using:

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

Once you figure out which window, you can reach it like this:

driver.SwitchTo().Window(driver.WindowHandles[1]);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.