How to verify that icon is not displayed or icon is displayed on the page ?

Image: enter image description here

Here it is html code if icon is not displayed:

<td id="messageGrid_tccell1_7" class="txtleft dxgv"/>

Here it is html code if icon is displayed:

<td id="messageGrid_tccell2_7" class="txtleft dxgv">
<div class="locked" title="locked"/>
  • What is the behavior of this icon on webpage. Can explain more? Feb 28, 2018 at 4:24

2 Answers 2


Easiest way is to use the ExpectedConditions class.

For example, if you call ElementIsVisible() with the locator of the inner <div> element it will only return true if it's there.

  • Can someone show a sample code? Thank you.
    – user44706
    Apr 24, 2020 at 12:01

try the below code

WebElement element=driver.findelement(By.id("messageGrid_tccell2_7"))
System.out.println("Image displayed")
System.out.println("Image notdisplayed")
  • "messageGrid_tccell2_7" is the cell in which there is an icon or not. The cell is still present. So, this code can not be used to verify the status of the icon.
    – Majkl
    Feb 27, 2018 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.