Ad:
 
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 1646
  • VB.NET RSS
Similar Threads
Jan 26th, 2010
0

How to click submit?

Expand Post »
im trying to make a auto sign up in youtube but my problem is the " I accept" button doesnt have value in html so i try to use the id but i doesnt work help me please....

heres my code
VB.NET Syntax (Toggle Plain Text)
  1. Public Class Form1
  2. Public Sub BHMNavigate(ByRef Wb As WebBrowser, ByRef Url As String)
  3. Wb.Navigate(Url)
  4. Do While Wb.ReadyState <> WebBrowserReadyState.Complete
  5. Application.DoEvents()
  6. Loop
  7. End Sub
  8. Public Function FillOutForm(ByRef wb As WebBrowser, ByRef TagName As String, ByRef GetAttribute As String, ByRef ControlName As String, _
  9. ByRef SetAttribute As String, ByRef Value As String)
  10.  
  11. Dim theElementCollection As HtmlElementCollection = wb.Document.GetElementsByTagName(TagName)
  12.  
  13. For Each curElement As HtmlElement In theElementCollection
  14. Dim vcontrolName As String = curElement.GetAttribute(GetAttribute).ToString
  15. If vcontrolName = ControlName Then
  16. curElement.SetAttribute(SetAttribute, Value)
  17. Return 1
  18. End If
  19. Next
  20. Return 0
  21. End Function
  22. Public Sub ClickButton(ByRef wb As WebBrowser, ByRef value As String)
  23. 'Submit button
  24. Dim theElementCollection As HtmlElementCollection
  25. theElementCollection = wb.Document.GetElementsByTagName("Input")
  26. For Each curElement2 As HtmlElement In theElementCollection
  27. If curElement2.GetAttribute("id").Equals(value) Then
  28. curElement2.InvokeMember("click")
  29. Do While wb.ReadyState <> WebBrowserReadyState.Complete
  30. Application.DoEvents()
  31. Loop
  32. End If
  33. Next
  34.  
  35. End Sub
  36. Public Sub ClickButton2(ByRef wb As WebBrowser, ByRef id As String)
  37. 'Submit button
  38. Dim theElementCollection As HtmlElementCollection
  39. theElementCollection = wb.Document.GetElementsByTagName("Input")
  40. For Each curElement2 As HtmlElement In theElementCollection
  41. If curElement2.GetAttribute("id").Equals(id) Then
  42. curElement2.InvokeMember("click")
  43. Do While wb.ReadyState <> WebBrowserReadyState.Complete
  44. Application.DoEvents()
  45. Loop
  46. End If
  47. Next
  48.  
  49. End Sub
  50.  
  51. Private Sub btnGenerate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGenerate.Click
  52. BHMNavigate(WebBrowser1, "http://www.youtube.com/create_account?next=%2F")
  53. FillOutForm(WebBrowser1, "input", "id", "username", "value", "youtesttube")
  54. FillOutForm(WebBrowser1, "select", "id", "countrySelect", "value", "AU")
  55. FillOutForm(WebBrowser1, "select", "name", "birthday_mon", "value", "1")
  56. FillOutForm(WebBrowser1, "select", "name", "birthday_day", "value", "1")
  57. FillOutForm(WebBrowser1, "select", "name", "birthday_yr", "value", "1988")
  58. ClickButton(WebBrowser1, "male")
  59. ClickButton2(WebBrowser1, "button-signin")
Last edited by darcee; Jan 26th, 2010 at 3:02 am.
Reputation Points: 10
Solved Threads: 0
Light Poster
darcee is offline Offline
47 posts
since May 2008
Jan 27th, 2010
0

Re: How to click auto submit?

Use this Sub or modify ClickButton2:

Public Sub ClickAHref(ByRef wb As WebBrowser, ByRef id As String)
        'Submit button
        Dim theElementCollection As HtmlElementCollection
        theElementCollection = wb.Document.GetElementsByTagName("a")
        For Each curElement2 As HtmlElement In theElementCollection
            If curElement2.GetAttribute("id").Equals(id) Then
                curElement2.InvokeMember("click")
                Do While wb.ReadyState <> WebBrowserReadyState.Complete
                    Application.DoEvents()
                Loop
            End If
        Next

    End Sub
Last edited by farooqaaa; Jan 27th, 2010 at 1:37 pm.
Reputation Points: 52
Solved Threads: 65
Posting Whiz in Training
farooqaaa is offline Offline
257 posts
since Jul 2008
Jan 29th, 2010
0

Re: How to click auto submit?

thanks for the reply men... but ive already solve this problem by sending it by form name...
Reputation Points: 10
Solved Threads: 0
Light Poster
darcee is offline Offline
47 posts
since May 2008
This thread is more than three months old. Perhaps start a new thread instead?
Message:
Previous Thread in VB.NET Forum Timeline: Add Column
Next Thread in VB.NET Forum Timeline: How to capture captcha?





About Us | Contact Us | Advertise | Acceptable Use Policy
Build Custom RSS Feed


Follow us on Twitter


© 2010 DaniWeb® LLC