0

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

2
Contributors
5
Replies
21
Views
3 Years
Discussion Span
Last Post by mark103
0

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

Edited by cgeier

0

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

0

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?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.