When I click the button, the browser opens a new window, I look for the element in the open window and can not find it.
I think he has not changed to the new window and is still looking at the old window. Error:
org.openqa.selenium.NoSuchElementException: Unable to locate element
Code:
WebDriver iframe = navegador.switchTo().frame(navegador.findElement(By.name("topbar")));
WebElement link = iframe.findElement(By.id("user_role_link"));// procuro o elemento no Iframe
link.click(); // clico no botão
// abre uma nova janela
for(String winHandle : navegador.getWindowHandles()){ // alterna para a janela que esta aberta
navegador.switchTo().window(winHandle);
}
//tento procurar o elemento
element = navegador.findElementByName("user_role/user_role_xid_find");
element.click();