我必须编写简单的程序来点击Internet Explorer,已经开始,但是由于我在编程方面的经验不足,被困住了。在第一页11.html我需要点击带有文字“Sign1”的按钮,在下一个“Sign2”上在Internet Explorer中点击
//11.html
<input type="button" class="button" onclick="document.location='21.html'" value="Sign1">
//21.html
<input type="button" class="button" onclick="document.location='31.html'" value="Sign2">
什么是错?第二个按钮不起作用。
Public Class Form1 Public ie = CreateObject("InternetExplorer.Application")
Private Sub Button2_Click_1(sender As Object, e As EventArgs) Handles Button2.Click
ie.Visible = True
ie.navigate("http://....com/11.html")
Do
Loop Until ie.ReadyState = 4
Actions()
End Sub
Private Sub Actions()
Dim eInputs = ie.Document.GetElementsByTagName("input")
For Each eInput In eInputs
If eInput.GetAttribute("value") = "Sign1" Then
eInput.Click()
Exit For
End If
Next
Threading.Thread.Sleep(5000)
//here ie href is about:blank - WHY???
eInputs = ie.Document.GetElementsByTagName("input")
For Each eInput In eInputs
If eInput.GetAttribute("value") = "Sign2" Then
eInput.Click()
Exit For
End If
Next
End Sub
End Class
我不之间放认为西里尔字母可以被硬编码。这就是它应该是错误的,编译器会将它们编译为“???????” –
感谢您的回复西里尔字母不起到任何作用:如果eInput.GetAttribute(“值”)=“SIGN1”那......如果eInput.GetAttribute(“值”)=“SIGN2”那... –
在第二部分,即变量的href属性是关于:空白。那就是问题所在。 –