Como o driver da web selenium pode saber quando a nova janela é aberta e depois retomar sua execução
stou enfrentando um problema ao automatizar um aplicativo Web usando o driver seleniu
A página da web possui um botão que, quando clicado, abre uma nova janela. Quando eu uso o código a seguir, ele lançaOpenQA.Selenium.NoSuchWindowException: No window found
WebDriver.FindElement(By.Id("id of the button that opens new window")).Click();
//Switch to new window
_WebDriver.SwitchTo().Window("new window name");
//Click on button present on the newly opened window
_WebDriver.FindElement(By.Id("id of button present on newly opened window")).Click();
Para resolver o problema acima, adicionoThread.Sleep(50000);
entre o botão, clique eSwitchTo
afirmações
WebDriver.FindElement(By.Id("id of the button that opens new window")).Click();
Thread.Sleep(50000); //wait
//Switch to new window
_WebDriver.SwitchTo().Window("new window name");
//Click on button present on the newly opened window
_WebDriver.FindElement(By.Id("id of button present on newly opened window")).Click();
Resolveu o problema, mas não quero usar oThread.Sleep(50000);
porque, se a janela demorar mais para abrir, o código poderá falhar e se a janela abrir rapidamente, o teste será lento desnecessariament
Existe alguma maneira de saber quando a janela foi aberta e o teste pode continuar sua execuçã