Estoy tratando de hacer clic en el enlace 'New Trade' que está en el intervalo n6, que es un elemento secundario del intervalo n2. Puedo llegar hasta n2 pero no identifica 'n6'. Por favor ayuda Soy nuevo en Selenium WebDriver
Aquí estoy publicando el html y mi código.
Comercio
Nuevo comercio
Explorador comercial
Quiero hacer clic en New Trade
Mi código que fue hasta el intervalo 'n2':
driver.switchTo().frame(driver.findElement(By.name("treeFrame")));
WebElement allFormChildElements = driver.findElement(By.name("the_form"));
allFormChildElements.findElement(By.linkText("Trading")).click();
WebElement modalDialog = allFormChildElements.findElement(By.className("border"));
WebElement newmodalDialog = modalDialog.findElement(By.className("formScrollableMenuContent"));
System.out.println(newmodalDialog.findElements(By.tagName("a")).size()); // ans 5
WebElement newDialog= newmodalDialog.findElement(By.id("n2"));
System.out.println(newDialog.findElements(By.id("n3")).size()); // ans 0
Con la imagen no puedo probar, pero, si puede llegar al elemento <span id="n2">
, desde allí puede usar el siguiente xpath para hacer clic en el elemento con el texto "New Trade":
newDialog.findElement(By.xpath(".//span[@id='n6']/a[@name='A6' and text()='New Trade']")).click();
EDITAR
Si el valor de id cambia, intente de esta manera:
newDialog.findElement(By.xpath(".//span/a[@name='A6' and text()='New Trade']")).click();
Este artículo se recopila de Internet, indique la fuente cuando se vuelva a imprimir.
En caso de infracción, por favor [email protected] Eliminar
Déjame decir algunas palabras