Hi guys,

I need your help, I'm working on my vb.net application as I want to click the button on the webpage when i click on the form button, but I'm having a problem with click the button on the webpage as it will do nothing when i click on the form button.

When I try this:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

WebBrowser1.Document.GetElementById("xhpc_message").InnerText = TextBox1.Text

Dim htmlElements As HtmlElementCollection = WebBrowser1.Document.All
For Each ClickOnElementButton As HtmlElement In htmlElements
    If ClickOnElementButton.GetAttribute("value") = "Post" Then
       ClickOnElementButton.InvokeMember("click")
    End If
Next
End Sub

Here is the html source:

<button value="1" class="_42ft _4jy0 _11b _4jy3 _4jy1 selected" type="submit">Post</button>

Does anyone know how I can click on the webpage button when i click on the form button?

I can't change the html source because i'm using facebook.

Thanks in advance

Try the following:

Dim htmlElements As HtmlElementCollection

htmlElements = WebBrowser1.Document.GetElementsByTagName("button")

For Each element As HtmlElement In htmlElements

    MessageBox.Show("element name: '" & element.Name & "'   InnerText: '" & element.InnerText & "'" & "  Type: '" & element.GetAttribute("type") & "'")

    If element.GetAttribute("type") = "submit" Then
        element.InvokeMember("Click")
        Exit For
    End If
Next

Thank you very much for your help. I want to know how I can select on the the textbox using the id "xhpc_message"?

I have no idea what you're talking about. What are you trying to do?

I'm trying to select the textbox on facebook then put the strings that i have put the text in the form textbox and click on the post button to post it on facebook. Can you help?

any idea??

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.