ImageTag istnieje w TR?

EDYTOWAĆ:

public bool getImage()
{
    IWebElement table = driver.FindElement(By.Id("DIV_ID_1"));

    string name = String.Format("//*[contains(text(), \'{0}\')]", 'TEST1');
    IWebElement element = table.FindElement(By.XPath(name));
    IWebElement parent = element.FindElement(By.XPath(".."));

    try
    {
        IWebElement image = element.FindElement(By.XPath("//img"));
    }
    catch (NoSuchElementException e)
    {
        return false;
    }

    return true;
}

Jak dowiem się, czyTEST1 miećImage? w poniższym kodzie źródłowym HTML mam tr i wewnątrz tr mam td, a niektóre tr mogą mieć znacznik obrazu, a inne nie

Więc przekażę nazwę na przykład:TEST1 w zwrotach będę oczekiwał, czy nazwa ma tag Image, czy nie.

znowu, jeśli przejdęTEST2 iTEST3 powinnoreturn null ponieważ nie ma znacznika obrazu i gdzie jakoTEST1 iTEST4 miećImage tag dlatego powinien mnie przywrócić.

Próbowałem czegoś takiego, ale nie działało:

string name = String.Format(".//td[contains(., \'{0}\')]/..//@src", "TEST1");
IWebElement element = driver.FindElement(By.XPath(name));

ten błąd: po wypróbowaniu powyższego kodu ...

Wyrażenie xpath '.// td [zawiera (.,' TEST1 ')] /..//@ src' nie może być ocenione lub nie występuje w WebElement

Poniżej znajduje się kod źródłowy HTML

<div id="DIV_ID_1">
    <table id="TBLID1">
        <tr>
            <td>
                TEST1
            </td>
            <td>
                <img id="ctl00" src="../App_Themes/Default/images/phone.gif" />
            </td>
        </tr>
        <tr>
            <td>
                TEST2
            </td>
        </tr>
        <tr>
            <td>
                TEST3
            </td>
        </tr>
        <tr>
            <td>
                TEST4
            </td>
            <td>
                <img id="ctl02" src="../App_Themes/Default/images/phone.gif" />
            </td>
        </tr>
    </table>
</div>

questionAnswers(2)

yourAnswerToTheQuestion