Results 1 to 12 of 12

Thread: [Resolved]Entering text into a webbrowser field.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2009
    Posts
    79

    [Resolved]Entering text into a webbrowser field.

    Hi, I want to make it so I have a form and a button and a web browser.

    The web browser will automatically load to a website that has boxes to fill in.

    In google chrome when i right click on the text box i can find the element or whatever its called.

    I am just wondering how I can make it so when I press the button it will change the text of the textbox on the website to whatever I want.


    Also how to make it press a button on a web browser as well.

    (All of this while the browser is invisible)

    Thanks for the help!
    Last edited by WookieVagina; Mar 26th, 2010 at 10:01 PM. Reason: Resolved.

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,416

    Re: Entering text into a webbrowser field.

    can you tell me the url you're talking about?
    it'll help to see the html, because no 2 webpages are the same

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2009
    Posts
    79

    Re: Entering text into a webbrowser field.

    I'm actually trying to make a form that has many different text boxes.

    It signs you up for a game so you can make multiple accounts quickly.

    the link is
    Code:
    http://passport.nexon.net/Registration/Signup.aspx?nexonTheme=Maplestory
    and this is what my form looks like:



    I remember making something similar to this before and it had to do with the element name of the text box I wanted to enter something in.

    For example, the first textbox on that site for Account ID is "txtAccountId"

    EDIT2: And if possible after I get my application working, I would like to add to check if the name is available like it does on the website.

    I also don't want it to just show the website in a web browser because it is cleaner this way and there would be no point in even making the program in the first place.

    EDIT3: Also I am going to make it show the captcha image in that space with the gray lines. The captcha image id is "captchaFS_Image"
    Last edited by WookieVagina; Mar 26th, 2010 at 07:52 PM.

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,416

    Re: Entering text into a webbrowser field.

    try this:

    vb Code:
    1. Public Class Form1
    2.  
    3.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    4.         WebBrowser1.Navigate("http://passport.nexon.net/Registration/Signup.aspx?nexonTheme=Maplestory")
    5.         Do While WebBrowser1.ReadyState <> WebBrowserReadyState.Complete
    6.             Application.DoEvents()
    7.         Loop
    8.         Dim el As String = ""
    9.         For Each element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("input")
    10.             el &= element.Name & Environment.NewLine
    11.         Next
    12.         MsgBox(el)
    13.         WebBrowser1.Document.All("txtAccountId").InnerText = "AccountId"
    14.         WebBrowser1.Document.All("txtPassword").InnerText = "Password"
    15.         WebBrowser1.Document.All("txtPasswordConfirmation").InnerText = "PasswordConfirmation"
    16.         WebBrowser1.Document.All("txtEmail").InnerText = "Email"
    17.         WebBrowser1.Document.All("txtEmailConfirmation").InnerText = "EmailConfirmation"
    18.         WebBrowser1.Document.All("txtFirstName").InnerText = "FirstName"
    19.         WebBrowser1.Document.All("txtLastName").InnerText = "LastName"
    20.         For Each element As HtmlElement In Me.WebBrowser1.Document.All("ddlBirthMonth").GetElementsByTagName("option")
    21.             If element.GetAttribute("text") = "January" Then
    22.                 element.SetAttribute("selected", "True")
    23.                 Exit For
    24.             End If
    25.         Next
    26.         For Each element As HtmlElement In Me.WebBrowser1.Document.All("ddlBirthDay").GetElementsByTagName("option")
    27.             If element.GetAttribute("text") = "1" Then
    28.                 element.SetAttribute("selected", "True")
    29.                 Exit For
    30.             End If
    31.         Next
    32.         For Each element As HtmlElement In Me.WebBrowser1.Document.All("ddlBirthYear").GetElementsByTagName("option")
    33.             If element.GetAttribute("text") = "2001" Then
    34.                 element.SetAttribute("selected", "True")
    35.                 Exit For
    36.             End If
    37.         Next
    38.         WebBrowser1.Document.GetElementById("rbGenderMale").SetAttribute("checked", "true")
    39.         WebBrowser1.Document.GetElementById("rbGenderFemale").SetAttribute("checked", "")
    40.         WebBrowser1.Document.All("txtCaptcha").InnerText = "Captcha"
    41.         WebBrowser1.Document.All("chkNewsletter").SetAttribute("checked", "true")
    42.         WebBrowser1.Document.All("chkTermofuse").SetAttribute("checked", "true")
    43.         WebBrowser1.Document.All("btnSubmit").InvokeMember("click")
    44.     End Sub
    45. End Class

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,416

    Re: Entering text into a webbrowser field.

    EDIT2/ pass
    EDIT3/ pass

    that leaves you with something to research + find the answers to. if you search this forum i'm sure there is something about webbrowser images

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Mar 2009
    Posts
    79

    Re: Entering text into a webbrowser field.

    WOW! Thanks so much.

    Okay this is what I have so far.

    Code:
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            WebBrowser1.Document.All("txtAccountId").InnerText = TextBox1.Text
            WebBrowser1.Document.All("txtPassword").InnerText = MaskedTextBox1.Text
            WebBrowser1.Document.All("txtPasswordConfirmation").InnerText = MaskedTextBox1.Text
            WebBrowser1.Document.All("txtEmail").InnerText = TextBox2.Text
            WebBrowser1.Document.All("txtEmailConfirmation").InnerText = TextBox2.Text
            WebBrowser1.Document.All("txtFirstName").InnerText = TextBox6.Text
            WebBrowser1.Document.All("txtLastName").InnerText = TextBox7.Text
            If RadioButton1.Checked = True Then
                WebBrowser1.Document.GetElementById("rbGenderMale").SetAttribute("checked", "true")
            Else
                WebBrowser1.Document.GetElementById("rbGenderFemale").SetAttribute("checked", "true")
            End If
            WebBrowser1.Document.All("txtCaptcha").InnerText = TextBox3.Text
            WebBrowser1.Document.All("chkNewsletter").SetAttribute("checked", "false")
            WebBrowser1.Document.All("chkTermofuse").SetAttribute("checked", "true")
            WebBrowser1.Document.All("btnSubmit").InvokeMember("click")
        End Sub
    But I'm not sure how to set the birth date.

    The Month drop down list is:
    Code:
    January
    February
    March
    April
    May
    June
    July
    August
    September
    October
    November
    December
    The day is:
    Code:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    The years are:
    Code:
    1997
    1996
    1995
    1994
    1993
    1992
    1990
    1989
    1988
    1987
    1986
    1985
    1984
    1983
    1982
    1981
    1980
    I'm just not sure how to make it select the same birthday that is chosen in the program.

    Also, I'm not sure how to make the captcha show in the program where that gray box is.


    EDIT: Also, the years on my program selection aren't the same as the websites ones, mine has much less.

  7. #7
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,416

    Re: Entering text into a webbrowser field.

    i told you how in post #4

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Mar 2009
    Posts
    79

    Re: Entering text into a webbrowser field.

    I'm still having trouble with it.

    when i do:

    Code:
    For Each element As HtmlElement In Me.WebBrowser1.Document.All("ddlBirthDay").GetElementsByTagName("option")
                If element.GetAttribute("text") = "1" Then
                    element.SetAttribute("selected", "True")
                    Exit For
                End If
            Next
    It sets the day to 1.

    I am trying to make it so you can choose the day using my ComboBox2 which has all numbers 1 through 31 in it.

    I really don't know how. =/

  9. #9
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,416

    Re: Entering text into a webbrowser field.

    If element.GetAttribute("text") = "1" Then

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Mar 2009
    Posts
    79

    Re: Entering text into a webbrowser field.

    Quote Originally Posted by .paul. View Post
    If element.GetAttribute("text") = "1" Then
    yeah I tried adding more of those, but it still sets it as 1 no matter what i choose in my combobox. I just don't know how to associate the browsers box with the forms combobox.

  11. #11
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,416

    Re: Entering text into a webbrowser field.

    vb Code:
    1. If element.GetAttribute("text") = ComboBox2.selecteditem.tostring Then

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Mar 2009
    Posts
    79

    Re: Entering text into a webbrowser field.

    wow.. i feel so stupid LOL

    Thanks so much for that I got the days working

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width