Results 1 to 35 of 35

Thread: [RESOLVED] Web browser control Problem?

  1. #1

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Resolved [RESOLVED] Web browser control Problem?

    I am using a web browser control to autologin to a webpage. When I intially gives the username and password,it works well.
    And for the second time it is not taking the username and password from the code.I dont know where it take from I get the err messeag as attached here.
    And the code is

    VB Code:
    1. wb1.Navigate "http://www.netwealth.com.au/"
    2.     Do Until wb1.ReadyState = READYSTATE_COMPLETE
    3.         DoEvents
    4.     Loop
    5. wb1.Document.login.username.Value = "usernamehere"
    6. wb1.Document.login.password.Value = "mypassword"
    7. wb1.Document.login.submit

  2. #2
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Web browser control Problem?

    Try placing the wb1.Document code in the WebBrowser1_DocumentComplete() Event.

  3. #3

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Web browser control Problem?

    Please explain. I couldnot get u.

  4. #4
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Web browser control Problem?

    From memory, the READYSTATE_COMPLETE occurs prior to DocumentComplete. That said
    your wb1.Document wouldn't exist at this stage, of course until COMPLETE. Therefore,
    (ditching the Do?Loop) and placing the .Document code in the relavent event should
    ensure the Documnet object is in fact loaded.

    Hope that makes sense .

  5. #5

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Web browser control Problem?

    I still face the same problem

  6. #6

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Web browser control Problem?

    I think it is getting the informations from either cookies or session?.Some body help to overcome this problem

  7. #7
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Web browser control Problem?

    Is it not (Type = Text) 'name' that you need to pass UserName to?

  8. #8

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Web browser control Problem?

    Yes ? I need to pass the username and password also.Form method is post.

  9. #9
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Web browser control Problem?

    did you tryit in the Doc Complete event as bruce said?

    as far as readystate_complete... it can fire more than once... and also will fire early if in memory...

    VB Code:
    1. Private Sub Form_Load()
    2.     wb1.Navigate "http://www.netwealth.com.au/"
    3. End Sub
    4.  
    5. Private Sub wb1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    6.     Debug.Print URL
    7.     If (pDisp Is wb1.Application) Then
    8.        
    9.         wb1.Document.login.username.Value = "usernamehere"
    10.         wb1.Document.login.password.Value = "mypassword"
    11.         wb1.Document.login.submit
    12.  
    13.        
    14.     End If
    15. End Sub

    take a look at the webbrowser tutorial in my sig....
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  10. #10

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Web browser control Problem?

    Dear Static,
    I still face the same problem.(object doesnot support this type).Is there any other method to auto submit a web page??

  11. #11
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Web browser control Problem?

    try this:

    wb1.Document.all.username.Value = "usernamehere"
    wb1.Document.all.password.Value = "mypassword"
    wb1.Document.all.submit.click
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  12. #12
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Web browser control Problem?

    if it still does it.. there may be another issue...
    do this:

    run it.. let it login.. when it gets to the login again and fails.. view source of the webbpage.. save it to a text and post it. lets take a look at it.

    it seems whats happening is the objects are changing somehow.. OR there are multiple objects with the same name..
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  13. #13

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Web browser control Problem?

    Dear Static!,
    First time the web page loads automatically with the username and password. And after some time that is in the document complete event is giving this error message. It is firing again and again.

    If i end the program and re run the program it is loading automatically and goes to the welcome screen. The the document complete event fires. Then i get the error msg as posted here.
    Attached Images Attached Images  

  14. #14
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Web browser control Problem?

    wait.. are you loggin in to VBF with this??
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  15. #15

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Web browser control Problem?

    I tried this with other one site, but that site username and pwd is confi one.So i am trying this with our site. So that i can give the username and pwd.

  16. #16
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Web browser control Problem?

    ok.. heres the issue..
    once Logged in.. (at least with our site).. the login username/password is gone. thats why u are getting the error.. you need to put a check in to see if the objects are there
    you need a ref to the MS HTML Object Library

    like this...
    VB Code:
    1. Public Function LoggedIn(HTML As HTMLDocument) As Boolean
    2.     On Error GoTo checkerr
    3.     Dim txt As HTMLInputTextElement
    4.     Set txt = HTML.All.vb_login_username
    5.     LoggedIn = False
    6.     Exit Function
    7. checkerr:
    8.     LoggedIn = True
    9. End Function
    10.  
    11.  
    12. Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    13.     If (pDisp Is WebBrowser1.Application) Then
    14.         If Not LoggedIn(WebBrowser1.Document) Then
    15.             WebBrowser1.Document.All.username.Value = "xxxxx"
    16.             'etc...
    17.         End If
    18.     End If
    19. End Sub
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  17. #17

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Web browser control Problem?

    Dear Static,
    I am facing problem submit the form. I use the webbrowser1.document.submit. But it gives an error message of object doesnot property

  18. #18

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Web browser control Problem?

    And also it logs in automatically without checking the username and pwd.I couldnot able to get where it is getting the entries old entries wheather history or not?

  19. #19
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Web browser control Problem?

    where.. here? (in VBF)?
    thats cause in VBF its a tricky button.. not typical button
    heres is the code I use for my VBF webbrowser... this sets the username/password then clicks submit
    VB Code:
    1. Dim HTMLS As HTMLInputButtonElement
    2.             HTML.All.vb_login_username.Value = USER
    3.             HTML.All.vb_login_password.Value = PSWD
    4.             'Loop thru all input elements, find the type = submit with value of Log in
    5.             For Each HTMLS In HTML.getElementsByTagName("input")
    6.                 If HTMLS.Type = "submit" And HTMLS.Value = "Log in" Then
    7.                     HTMLS.Click
    8.                     Exit For
    9.                 End If
    10.             Next
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  20. #20

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Web browser control Problem?

    In the error object required err msg in the line

    For Each HTMLS In HTML.getElementsByTagName("input")

  21. #21

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Web browser control Problem?

    I have placed the varriable declartion also.?

    Dim HTMLS As HTMLInputButtonElement

  22. #22
    Hyperactive Member Datacide's Avatar
    Join Date
    Jun 2005
    Posts
    309

    Re: Web browser control Problem?

    Is it VBF that your trying to log into? or http://www.netwealth.com.au?
    PHP in your FACE!

  23. #23
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Web browser control Problem?

    dana.. did you add a reference to the Microsoft HTML object Library?


    and did you

    Set HTML = Webbrowser1.Document ?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  24. #24

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Web browser control Problem?

    Dear Static ,
    I am trying it.

  25. #25

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Web browser control Problem?

    Dear Static,
    I have missed the line
    Set HTML = Webbrowser1.Document.
    So only It was giving the error msg. Thanks for the reply.
    Really you are wonderfull!!!!
    Great Help?

  26. #26

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Web browser control Problem?

    Dear Static!
    Really you are great!!!!!.

  27. #27
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: [RESOLVED] Web browser control Problem?

    I have a good tutorial (at least I THINK its good lol) on my website..
    link in my sig...

    glad to help.. webbrowser stuff is my favorite!
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  28. #28

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: [RESOLVED] Web browser control Problem?

    Thanks static.!!

  29. #29

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: [RESOLVED] Web browser control Problem?

    Dear Static,
    In the form i have filed called file.This is used for uploading files.In the browser window there is button called with value "Browse". If I click the browse button then a open dialog box is displayed. In that I have to select a file and click ok. I want to automate this one, How can I?

  30. #30
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: [RESOLVED] Web browser control Problem?

    Im not sure what u want to automate...

    The upload?
    -put the file in a field in a web form and submit?
    -ftp?
    The file select?
    -meaning, you wont have to click a button to select a file??

    please explain more...
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  31. #31

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: [RESOLVED] Web browser control Problem?

    I want to upload a particular file to one a webpage. I have given the screen shot of that page.If I click the browse button a dialog box pop up and I have to select the file and click ok. As soon as I click the ok button it will display the file path in the text area. Here the that are is given as
    Code:
    <INPUT name="f_data" size="50" type="file">
    I am not able to assign the value to this. If I am able to load the values then I can click the upload button as mentioned by you in this post.
    Attached Images Attached Images  

  32. #32
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: [RESOLVED] Web browser control Problem?

    temporary fix... i HATE that I had to use sendkeys!!!

    I will continue to try other ways.. but for some reason.. i CANT set the value. excpet by the browse button.. unless done this way.. which does work

    VB Code:
    1. Private Sub UpFile(HTML As HTMLDocument, fName As String)
    2.     Dim F_Inp As HTMLInputElement
    3.     Set F_Inp = HTML.All.Item("f_data")
    4.     F_Inp.focus
    5.     SendKeys fName
    6. End Sub
    7.  
    8. Private Sub Command1_Click()
    9.     UpFile WebBrowser1.Document, "C:\Path\to\file.txt"
    10. End Sub
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  33. #33

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: [RESOLVED] Web browser control Problem?

    Dear Static,
    I am not able to set the value with this code.

  34. #34
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: [RESOLVED] Web browser control Problem?

    post the code that you are using...

    you should be able to add this sub
    VB Code:
    1. Private Sub UpFile(HTML As HTMLDocument, fName As String)
    2.     Dim F_Inp As HTMLInputElement
    3.     Set F_Inp = HTML.All.Item("f_data")
    4.     F_Inp.focus
    5.     SendKeys fName
    6. End Sub
    then call it where you want to se the value..
    pass in the doc and the path to the file
    VB Code:
    1. UpFile WebBrowser1.Document, "C:\Path\to\file.txt"
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  35. #35

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: [RESOLVED] Web browser control Problem?

    Dear Static,
    This is working fine.Thanks for ur help.

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