API Testing using Rest Assured

Sunday, May 31, 2020

How to verify Success message or Warning message or Tooltip in selenium?

Common scenario we get while automating something is to check assertion after performing any action ( create , update , delete )

In this case we usually get some messages on screen that is getting disappear after sometime. and problem we face that we cant inspect them because it gets disappear.

In order to verify those kind of messages i got something which i am sharing here which might help you :)

Here, in this example i am showing example of wordpress while deleting the post we are getting one success message as 'Post is deleted successfully' which gets disappear when we try to inspect it so how can we inspect it like this






In order to inspect it

Step no 1:- After performing an operation go to the Inspect element > Sources TAB and click on Pause button below like this





it will stop the script execution.


Step no 2:- Now, go that message and try to inspect it





Step no 4:- Get the X-path of that element 





Step no 5:- Get the X-path of that element and use .getText() method to fetch value into it. and use it for assertion.


@FindBy(how=How.XPATH,using="//span[@class=\"notice__text\"]")
@CacheLookup 
public WebElement deletepost_message;


String delete_message=pom.deletepost_message.getText();
System.out.println("post is deleted and success message displayed as    "+ delete_message);

No comments:

Post a Comment