如何点击innerhtml数据,如果启动代码td



我想点击innerhtml区域,但当我使用我的代码,然后它完全不工作,但当我尝试web浏览器包含然后消息显示工作良好。我想我搞错了什么,请帮帮我。

html代码

<td class="messageline__box">
    <a class="messageline__link" href="/message/14418316360000000524">
        <span class="messageline__from">
            your billing available
        </span>
        <span class="messageline__subject">
            your well position, adep khan
        </span>
    </a>
</td>

My trying code

if (webBrowser1.DocumentText.Contains("Confirm your Twitter account"))
        {
            Thread.Sleep(150);

            foreach (HtmlElement el in webBrowser1.Document.GetElementsByTagName("span"))
            {
                if (el.InnerText == ("your well position"))
                {
                    el.InvokeMember("Click");
                }
            }
            MessageBox.Show("Working Well");

        }

请检查&给我的想法,我是如何点击继续我的工作。

您需要更仔细地调试代码。需要单击的span具有较长的内部文本值(your well position, adep khan)。因此,您需要使用String.Contains:

if (el.InnerText.Contains("your well position"))
{
     el.InvokeMember("Click");
}

最新更新