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? – Shailendra Rathore Feb 28 '18 at 4:24

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.

| improve this answer | |
  • Can someone show a sample code? Thank you. – Kent Abrio Apr 24 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")
| improve this answer | |
  • "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 '18 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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