Reputation: 51
try{
WebDriverWait wait = new WebDriverWait(driver,8(;
if (wait.until(ExpectedConditions.alertIsPresent())== null)
{
Alert alert = driver.switchTo().alert();
String aamessage = alert.getText();
if(aamessage.equals("invoked")) /// this text is in input box in Alert pop up, I am able to edit this message in alert pop up.
{
alert.accept();
}
else
{
syso("no alerts");
}
}
catch(unHandledAlertException f)
{}
catch(NoAlertPresentException h)
{}
To get the text message which is in Input box, i tried this. BUt code not getting that message. Do we have any thing in specific in such cases.
Also in few functionalities, where the alert pop-ups are displayed, I handled it and used alert.accept(). But still the exception "unhandledalert" is displayed in the console. How to avoid this.
Upvotes: 0
Views: 260
Reputation: 4177
Check this :
Alert alert = driver.switchTo().alert();
WebElement element=driver.findElement(By.id("input id"));
System.out.println("Input text value:- " +element.getAttribute("value"));
Upvotes: 1