As the title says i am trying to click this button...
Pic (The save one)
on this webpage...
http://upload.youtube.com/my_videos_upload?restrict=html_form

I have been trying various permutatuons of this

Dim j As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("BUTTON")
        For Each elem As HtmlElement In i
            elem.InvokeMember("click")
        Next

With little luck, i also tried to find the element bytagname of Class and it couldnt find it...

My whole code (for this procedure) is here.

End Sub

    Private Sub ButtonX3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX3.Click
        Dim f As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
        For Each elem As HtmlElement In f
            If elem.GetAttribute("name") = "title" Then
                elem.SetAttribute("value", txtTitle.Text)
            End If
            If elem.GetAttribute("name") = "keywords" Then
                elem.SetAttribute("value", txtKeyWords.Text)
            End If
        Next

        Dim i As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("textarea")
        For Each elem As HtmlElement In i
            If elem.GetAttribute("name") = "description" Then
                elem.SetAttribute("value", txtDescription.Text)
            End If
        Next
        Dim value As Integer

        Dim h As HtmlElementCollection
        Dim g As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("select")
        For Each elem As HtmlElement In g
            h = elem.Children
        Next
        For Each elem As HtmlElement In h
            If ComboBoxEx1.SelectedText = elem.InnerText Then
                value = elem.GetAttribute("value")
            End If
        Next

        For Each elem As HtmlElement In g
            elem.SetAttribute("value", value)
        Next


        Dim j As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("BUTTON")
        For Each elem As HtmlElement In i
            elem.InvokeMember("click")
        Next



    End Sub

Recommended Answers

All 3 Replies

Bump for new location!

Bump!

I use this to load and login to a site from a made form but should work or give you an idea.

Private Sub LogInSub()
        On Error GoTo err1
        WebBrowser1.Navigate(" webaddress")
        While WebBrowser1.ReadyState <> WebBrowserReadyState.Complete
            Application.DoEvents()
        End While
        Dim theElementCollection As HtmlElementCollection
        theElementCollection = WebBrowser1.Document.GetElementsByTagName("Input")
        For Each curElement As HtmlElement In theElementCollection
            Dim controlName As String = curElement.GetAttribute("id").ToString
            If controlName = "email" Then
                curElement.SetAttribute("Value", "username for site")
            End If
        Next
        theElementCollection = WebBrowser1.Document.GetElementsByTagName("Input")
        For Each curElement As HtmlElement In theElementCollection
            Dim controlName As String = curElement.GetAttribute("id").ToString
            If controlName = "password" Then
                curElement.SetAttribute("Value", "password for site")
            End If
        Next
        WebBrowser1.Document.Forms("login_pw").InvokeMember("submit")

err1:
        Exit Sub
    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.