Quality Testing

Quality is delighting customers

How to verify toast message using Selenium WebDriver?

How to verify "Please fill out this field" text using Selenium WebDriver?

Views: 67

Reply to This

Replies to This Discussion

To verify toast message by using selenium web driver, most of the software testing services use below approach:
Toast messages is a fast way of telling the user about some action or event. it's a short pop-up message that shows for a short time(for a second) then fade away.

To get the message on toast popup:
Open page source where the toast is shown and find toast element(press f12 and found element value). where you can find id or class name or div which you can select with selenium and get the message on that toast.

so you can use this in the same way as a software company can do.

driver.findElement(By.id("<toast_id>")) or driver.findElement(By.className("<toast_classname>")) to check it's text value in java

If toast is disappeared with in seconds

try{
assertThat(message.isDisplayed())
}
catch(Exception e){
//Log unable to verify message displayed
}
String messageText = ((JavascriptExecutor) driver).executeScript("return arguments[0].innerHTML", message);
assertThat(messageText,equals("expected");

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2019   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service