我正在尝试单击表单提交按钮,我已经能够填写表单字段,但由于缺少可以用来识别它的东西,我很难触发提交按钮?
Instagram:
<button class="_ah57t _84y62 _i46jh _rmr7s">Sign up</button>
如何在没有 ID 或任何不会混淆的强标识符的情况下单击按钮?
我如何处理输入字段
private void FindAndFillElement(string tag, string attribute, string attributeValue, string attributeReplace, string attributeReplaceValue)
{
foreach (HtmlElement elem in webBrowser1.Document.GetElementsByTagName(tag))
{
if (elem.GetAttribute(attribute) == attributeValue)
{
elem.SetAttribute(attributeReplace, attributeReplaceValue);
}
}
}
调用:
FindAndFillElement("input", "name", "emailOrPhone", "value", "some-email@mail.com");
最佳答案
不需要按钮,只需调用表单提交函数
document.getElementById("myForm").submit();
关于javascript - C# 在不知道 ID 或任何强标识符的情况下单击表单中的按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45090223/