1

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"/>
</td>
1
  • What is the behavior of this icon on webpage. Can explain more? Feb 28, 2018 at 4:24

2 Answers 2

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.

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

try the below code

WebElement element=driver.findelement(By.id("messageGrid_tccell2_7"))
if(element.isdisplay())
{
System.out.println("Image displayed")
}else{
System.out.println("Image notdisplayed")
}
1
  • "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 that you have read and understand our privacy policy and code of conduct.

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