I am want click innerhtml area but when I am using my code then it's totally not working but when I am try web browser contain then message show working well. I think I am mistaken something pls help me.
html code
<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");
}
Please check & give me idea how I am click with continue my work.
You need to debug your code more carefully. The span
you need to click has a longer inner text value (your well position, adep khan
). Thus, you need to use String.Contains
:
if (el.InnerText.Contains("your well position"))
{
el.InvokeMember("Click");
}