我需要一个元素按类型在C#中的HTML看起来是这样的:
I need to get a element by type in C# the HTML looks like this:
<button type="submit" class="orangeBtn">Send Invitations</button>
和我希望它能够在那里我可以调用(点击),但它没有出现在C#中工作。我现在的code是:
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?
这是不是我的服务器,所以我不能编辑HTML或添加的jQuery。
This is NOT my server, so I can't edit the HTML or add jquery.
我在做一个自动化的应用程序发送邀请给朋友们,我想加入,但他们提出不作为上面看到一个ID或名称的按钮,所以反正是有有它调用(点击)在C#使用不同的方法?
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?
感谢。
您可以使用的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");
}
}