您好,我正在开发一个简单的帐户菜单,用于通过网络浏览器登录 Steam。我正在尝试在该人中创建一个自动签名按钮。我可以让按钮自动填写密码和用户名,但提交按钮不起作用。
这里是steam登录链接:Here
这是按钮的元素 View 。另请注意,它看起来像是分支到某种事件?
我有点困惑如何解决这个问题。有没有办法使用网络控制台以这种方式提交它?这是我到目前为止所得到的:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
WebBrowser1.ScriptErrorsSuppressed = True
WebBrowser1.Document.GetElementById("input_username").SetAttribute("value", TextBox1.Text)
WebBrowser1.Document.GetElementById("input_password").SetAttribute("value", TextBox2.Text)
WebBrowser1.Document.All("login_btn_signin").InvokeMember("click")
End Sub
最佳答案
正确检查您的图像后,我注意到您单击了错误的元素。那<div id="login_btn_signin">
element 只是一个容器,不执行任何操作。您应该点击底层 <button>
元素。
由于按钮本身没有 ID,您必须使用解决方法:
'Get the "login_btn_signin" parent/container div.
Dim LoginButtonContainer As HtmlElement = WebBrowser1.Document.GetElementById("login_btn_signin")
'Get the first found <button> element in the container div.
Dim LoginButton As HtmlElement = LoginButtonContainer.GetElementsByTagName("button")(0)
'Click the button.
LoginButton.InvokeMember("click")
关于javascript - 如何在 vb.net 网络浏览器中按下按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46775670/