views:

18

answers:

1

I'm trying to make an Aduto-Forum poster with VB.NET windows form application

This is the page, http://www.inviteshare.com/community/viewforum.php?id=9 First I'm trying to log-in automatically I insert username & pass but I can't click the Login button because there are 2 buttons with the same ID on the page. ( input type="image" name="submit" class="submit" value="submit" />

input type="image" name="submit" value="login" />)

How can I click the second button. I need to select the button by its value I suppose;

 Dim txtUser As HtmlElement = wb.Document.GetElementById("login_user")
 Dim btn As HtmlElement = wb.Document.All("submit")

 txtUser.SetAttribute("value", "wolfied")

 If btn.GetAttribute("value") = "login" Then
      btn.InvokeMember("click")
 End If

But it did not work, how can I select the button that I need?

A: 
    For Each elem As HtmlElement In wb.Document.GetElementsByTagName("input")
        If elem.GetAttribute("value") = "login" Then
            txtUser.SetAttribute("value", "wolfied")
            txtPass.SetAttribute("value", "xxxx")
            elem.InvokeMember("click")
        End If
    Next

I found the button by searching each element by its tag, then look for its value

wallace740