我正在开发一个vb.net应用程序。我有一个webbrowser,我需要在webform上填写一些信息,然后单击“提交”按钮。一切都好,除了提交,没有任何反应!请帮忙!
html页面:
<p>
<input id="submit" name="submit" type="submit" value="Publicar" />
</p>
我的代码:
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
If PAgina = 0 Then
Dim document As HtmlDocument = WebBrowser1.Document
Dim inputValue As HtmlElement = document.GetElementById("title")
inputValue.SetAttribute("value", "sdf fdd fh fgh fgh fg hfg hf ghfgh fg fg f hf fgh ")
inputValue = document.GetElementById("zone")
inputValue.SetAttribute("value", "Logroño")
inputValue = document.GetElementById("editor")
inputValue.SetAttribute("value", "Logroño s dfs dfs fsdfsd fsddfg dfg df gdf gdf gd df sd sd fsd fsdfsdfsdsdfsdf sdsdf")
inputValue = document.GetElementById("email")
inputValue.SetAttribute("value", "dfgdgrankkk@gmail.com")
WebBrowser1.AllowNavigation = True
**Dim submitButton As HtmlElement = document.GetElementById("submit")
submitButton.InvokeMember("submit")
' WebBrowser1.Document.Forms("post").InvokeMember("submit")**
PAgina = 1
End If
结束子
答案 0 :(得分:2)
尝试
.InvokeMember("click") ; // instead of "submit" ?
或尝试在提交前添加几秒延迟。