Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to write Assert condition to check a particular element is not displayed for dummy users?

By.xpath("//button[@id='Edit']")
  • This particular Edit button should be displayed for Admin users
  • If we login with a different user, we are not showing them the Edit Button
  • How to write Assert condition to verify Edit button is not displayed for other users

>Solution :

I will search for all elements with this XPath and put them in List:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

List<WebElement> elements = driver.findElements(By.Xpath("//button[@id='Edit']"));

Then I will check if the count (size) of the elements in the list is zero, this will mean that the element was not found.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading