...我已經尋找如何前點擊VB中的一個網頁鏈接,並得到了在這個網站實際上是一個很好的答案。但現在我想點擊另一個鏈接,並讓我張貼的代碼,所以它更容易理解。 (第一次問一個問題,這樣下去容易對我大聲笑)如何點擊一個網頁鏈接在Visual Basic
<div class="pauseButton" style="display: block;"><a href="#" address="true"></a></div>
這裏是我的代碼(這是潘多拉順便說一句,這裏是我的代碼,它讓您登錄)。
Public Class fMain
Dim elementCollection As HtmlElementCollection
Private Sub fMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
wb.Navigate("http://www.pandora.com")
End Sub
'buttons
Private Sub bLogin_Click(sender As Object, e As EventArgs) Handles bLogin.Click
elementCollection = wb.Document.GetElementsByTagName("input")
For Each ele As HtmlElement In elementCollection
If ele.GetAttribute("name").Equals("email") Then
ele.SetAttribute("Value", tbEmail.Text)
End If
If ele.GetAttribute("name").Equals("password") Then
ele.SetAttribute("Value", tbPassword.Text)
End If
If ele.GetAttribute("type") = "submit" Then
ele.InvokeMember("click")
End If
Next
End Sub
Private Sub bSignOut_Click(sender As Object, e As EventArgs) Handles bSignOut.Click
End Sub
Private Sub bPlay_Click(sender As Object, e As EventArgs) Handles bPlay.Click
Dim IsRightElement As Boolean = False
For Each ele As HtmlElement In wb.Document.Links
If IsRightElement Then
ele.InvokeMember("click")
IsRightElement = False
Exit For
End If
If ele.GetAttribute("class") = "playButton" Then
IsRightElement = True
End If
Next
End Sub
Private Sub bPause_Click(sender As Object, e As EventArgs) Handles bPause.Click
End Sub
Private Sub bFavorite_Click(sender As Object, e As EventArgs) Handles bFavorite.Click
End Sub
End Class
任何幫助將不勝感激,和對不起,如果我提出的問題令人困惑,但幾乎我知道如何點擊與特定的HREF =「link.com」的鏈接,但在這裏,唯一與任何區分播放按鈕其他按鈕就是它的href =「#」,所以沒有太大的幫助。再次感謝先進的。 (:
編輯:我試圖做一個潘多拉流光,我應該提到更早
退房這個帖子:http://stackoverflow.com/a/17595506/381273 – nicky 2013-07-11 14:41:38
@nicky謝謝你,是有很大幫助! – sociallymellow 2013-07-19 04:59:24