【发布时间】:2017-12-06 15:53:25
【问题描述】:
我在 vb.net 方面非常业余。当我在文本框中输入文本时,它应该能够在webbrowsercontrol上自动输入以及如何单击按钮登录,其中没有getelementbyid。
我也设法使第一部分正确,但是当我从浏览器内部单击登录按钮时,似乎有一个小错误。很久以前做过一个这样的项目,现在找不到源代码了,所以我又从头开始了。
网址:https://app.coins.ph/welcome/login
到目前为止,这是我的代码:
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
WebBrowser1.Document.GetElementById("username").InnerText = TextBox1.Text
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
For Each Element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("class") 'Depending on how the source code is formatted on the tag, you may also try Element.OuterHTML, Element.InnerText and Element.OuterText in the line below
If Element.OuterText.Contains("SIGN IN") Then
Element.InvokeMember("click")
Exit For
End If
Next Element
End Sub
Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged
WebBrowser1.Document.GetElementById("password").InnerText = TextBox2.Text
End Sub
【问题讨论】:
-
花几分钟学习how to ask.
-
呃,提问时,请多花几秒钟时间添加一个有用的标题。这种乞讨可能适用于网站上的所有 1500 万个问题,并且(a)您的问题并不比其他问题更重要,(b)您的问题正在为志愿者创建编辑工作,(c)您实际上是在要求反对会损害您获得好答案的机会,(d) 以上所有这些都是显而易见的。
-
“似乎有一个小错误” - 什么错误?我不知道.net,但看起来你的问题可以做更多的细节。请注意,人们不会访问您的网站来查找此信息 - 您需要为他们提供这些信息。
标签: vb.net