1
我打電話給一大堆列表框中的網頁,當每個頁面加載時,我想在定時器進入下一頁之前向用戶發送消息。該頁面包含具有文本框和發送表單內容的按鈕的表單。以下是我的代碼和我試圖提交的表單。VB.NET在文本框中輸入文本,然後按發送webbrowser
問題是,只要定時器進入下一個網頁,它就會將信息添加到文本框中,然後單擊該按鈕,但它在最後一分鐘完成,就像它正在加載下一頁一樣。沒有足夠的時間提交表格。我試過增加計時器的時間,但這一直沒有奏效。有人能指出我做錯了什麼嗎?提前致謝!
我的代碼:
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If counter > ListBox2.Items.Count - 1 Then
WebBrowser1.Navigate("http://www.myserver.com/listofusers.aspx")
counter = 0
Timer1.Enabled = False
Button1.Enabled = True
Button1.Text = "Message the unmessaged"
ListBox2.Items.Clear()
Else
Button1.Enabled = False
Button1.Text = "Working... "
WebBrowser1.Navigate(ListBox2.Items(counter))
Dim theElementCollection = WebBrowser1.Document.GetElementsByTagName("textarea")
For Each curElement As HtmlElement In theElementCollection
Dim controlName As String = curElement.GetAttribute("className").ToString
If controlName = "profile" Then
curElement.SetAttribute("value", "Your password is due to expire in 10 days, please change it as soon as possible")
End If
Next
Dim theElementCollection2 = WebBrowser1.Document.GetElementsByTagName("input")
For Each curElement As HtmlElement In theElementCollection2
If curElement.GetAttribute("className").Equals("button norm-green") Then
curElement.InvokeMember("click")
End If
Next
End If
counter = counter + 1
End Sub
形式:
<form action="sendmessage.aspx" method="post" name="sendmessage">
<div class="aligncenter">
<span class="headline txtBlue size16">Send a Quick Message!</span>
<input maxlength="40" name="subject" size="33" type="hidden"
value="Important information" />
<textarea class="profile" name="message"></textarea><br />
<input type="submit" class="button norm-green" style="" value="Send Quick Msg" name="sendmessage" />
</div>
</form>