PH Nabila:
Estoy tratando de hacer clic en el Sí / No botón en un mensaje de alerta emergente usando selenio (java) . Sé que tenemos aceptar funciones () hacer clic en el Ok botones de cualquier alerta, pero que no funciona en este caso.
Probé el siguiente código:
Alert alert = driver.switchTo().alert();
alert.accept();
Este es el código HTML del mensaje de alerta:
<div class="ui-dialog-buttonpane ui-widget-content ui-helper-clearfix">
<div class="ui-dialog-buttonset">
<button type="button" class="ui-button ui-widget ui-state-default ui-corner-
all ui-button-text-only" role="button" aria-disabled="false">
<span class="ui-button-text">Yes</span>
</button>
<button type="button" class="ui-button ui-widget ui-state-default ui-corner-
all ui-button-text-only" role="button" aria-disabled="false">
<span class="ui-button-text">No</span>
</button>
</div>
</div>
¡Por favor ayuda!
cruisepandey:
Usted puede simplemente hacer clic en Sí botón . (No hay necesidad de cambiar a alerta ):
código:
new WebDriverWait(driver,10).until(ExpectedConditions.elementToBeClickable(By.xpath("//span[text()='Yes']/parent::button"))).click();