I need to get a element by type in C# the HTML looks like this:
<button type="submit" class="orangeBtn">Send Invitations</button>
And I want it to be able to where I can invoke("click") it, but it isn't appearing to work in C#. My current code is:
HtmlElement m_SubmitField = m_Browser.Document.All["orangeBtn"];
if (m_SubmitField != null)
m_SubmitField.InvokeMember("click");
Is there an alternative working way to do this?
This is NOT my server, so I can't edit the HTML or add jquery.
I'm making an automated application to send invites to friends that I want to join, but they made the button without a id or name as seen above, so is there anyway to have it invoke("click") in C# using a different method?
Thanks.
You can use GetElementsByTagName
.
var elements = m_Browser.Document.GetElementsByTagName("button");
foreach (HtmlElement element in elements)
{
// If there's more than one button, you can check the
//element.InnerHTML to see if it's the one you want
if (element.InnerHTML.Contains("Send Invitations"))
{
element.InvokeMember("click");
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With