I would would like to capture the number show in the alert shown here. I have tried using the xpath
to click on it but it does not work. Appreciate any help.
WebElement attribute = driver.findElement(By.xpath("//span[@class='text']//a"));
I would would like to capture the number show in the alert shown here. I have tried using the xpath
to click on it but it does not work. Appreciate any help.
WebElement attribute = driver.findElement(By.xpath("//span[@class='text']//a"));
If it is a browser javascript alert, you need to use this:
//Click the link to activate the alert
driver.findElement(By.linkText("See an example alert")).click();
//Wait for the alert to be displayed and store it in a variable
Alert alert = wait.until(ExpectedConditions.alertIsPresent());
//Store the alert text in a variable
String text = alert.getText();
//Press the OK button
alert.accept();
First, click on the alert link. Then try the below code (it will switch to the present alert-box and fetch the text from that).
driver.switchTo().alert().getText();