Issue
The scenario here is I'm saving data and after a successful save a toast message is displayed but if I lets say save the toast message as a WebElement and verify .isDisplayed() won't work because I think it would be displayed as element would be present in DOM anyways so any other way to assert a data save in grid using toast message?
Solution
Here is an example for validation the toast is displayed I use in my project:
Assert.assertTrue(validateToastMessageAppearance("invalid Entitlement"));
Where validateToastMessageAppearance
method defined as
public boolean validateToastMessageAppearance(String message){
return waitForElementToBeVisible(String.format(toastMessage,message));
}
The method waitForElementToBeVisible
is defined as:
public boolean waitForElementToBeVisible(By.xpath(xpath)) {
try {
wait.until(ExpectedConditions.visibilityOfElementLocated(xpath));
return true;
}catch (Throwable t){
return false;
}
}
While toastMessage
is defined as
public String toastMessage = toast + textElement;
Where
public String toast = "//div[contains(@class,'ToastContent')]";
and
public String textElement = "//*[contains(text(),'%s')]";
Answered By - Prophet
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.