EDIT:
public bool getImage()
{
IWebElement table = driver.FindElement(By.Id(\"DIV_ID_1\"));
string name = String.
So I would break this up into a few steps.
First get your element:
WebElement element = driver.findElement(By.xpath("//*[contains(text(), 'TEST1')]"));
Then get the parent element:
WebElement parent = element.findElement(By.xpath(".."));
Then check the parent element for an tag:
Try
{
WebElement image = parent.findElement(By.xpath("//img"));
}
catch (NoSuchElementException e)
{
System.out.println("Did not find an image");
}
I'd wrap this in a function that I could then pass in the text to find the image and return the element if it exists.
Something like:
public WebElement getImage(String innerText)
then just pass in TEST1 or TEST2