Results 1 to 5 of 5

Thread: login code for dropbox not working. desperate for help

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2013
    Posts
    6

    login code for dropbox not working. desperate for help

    Please help me with the following code. After opening the link it does not like to enter in username and password. It is essential that they access through webbrowser form:


    Code:
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    
            Dim Web As New DropBoxWebBrowse
            Dim user = TextBox1.Text
            Dim pass = TextBox2.Text
    
            Web.Show()
            Web.WebBrowser1.Navigate("https://www.dropbox.com/login?lhs_type=anywhere")
    
            With Web.WebBrowser1
                .Document.GetElementById("login_email").SetAttribute("Value", user)
                .Document.GetElementById("login_password").SetAttribute("Init val", pass)
            End With
    
        End Sub

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: login code for dropbox not working. desperate for help

    Sigh... we see this so many times...
    the Navigate call is asynchronous... meaning that it isn't going to wait for the page to be loaded before continuing on. So what's happening is that it's running the next line before the page is loaded...

    what you need to do is move the last 4 lines to the DocumentLoaded event... that way when the Document is loaded, then the code will continue.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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

    Re: login code for dropbox not working. desperate for help

    rookie mistake


    my question is, with dropbox tools like direct access from your desktop, why do they need to login through your app?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  4. #4

    Thread Starter
    New Member
    Join Date
    May 2013
    Posts
    6

    Re: login code for dropbox not working. desperate for help

    Thanks for the suggestion. Soon after posting this question I continued to search for answers. I already tried to move to the documentloaded sub but it still fails to work. It is causing me to sigh too...


    Code:
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    
            Dim Web As New DropBoxWebBrowse
    
            Web.Show()
            Web.WebBrowser1.Navigate("https://www.dropbox.com/login?lhs_type=anywhere")
        End Sub
    Code:
     Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
    
                  'Part 2: Locate the Username TextBox and automatically input your username  
                '<input id="login_email" type="email" name="login_email" tabindex="1" />  
                Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("login_email")
                For Each curElement As HtmlElement In theElementCollection
                    Dim controlName As String = curElement.GetAttribute("input id").ToString
                    If controlName = "login_email" Then
                        curElement.SetAttribute("Value", DropBoxRegister.TextBox1.Text)
                    End If
                Next
    
                'Part 3: Locate the Password TextBox and automatically input your password  
                '<input type="password" id="login_password" name="login_password" tabindex="2" /> 
                theElementCollection = WebBrowser1.Document.GetElementsByTagName("login_password")
                For Each curElement As HtmlElement In theElementCollection
                    Dim controlName As String = curElement.GetAttribute("id").ToString
                    If controlName = "login_password" Then
                        curElement.SetAttribute("Value", DropBoxRegister.TextBox2.Text)
                    End If
                Next
    
                'Part 4: Locate the "Sign In" Button and automatically click it  
                '</div><input name="login_submit_dummy" value="Sign in" class="freshbutton-blue" type="submit" id="login_submit" tabindex="4" />  
                theElementCollection = WebBrowser1.Document.GetElementsByTagName("login_submit_dummy")
                For Each curElement As HtmlElement In theElementCollection
                    If curElement.GetAttribute("value").Equals("Sign in") Then
                        curElement.InvokeMember("click")
                        'Javascript has a click method for we need to invoke on the current submit button element.  
                    End If
                Next
        End Sub

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2013
    Posts
    6

    Re: login code for dropbox not working. desperate for help

    Quote Originally Posted by Static View Post
    rookie mistake


    my question is, with dropbox tools like direct access from your desktop, why do they need to login through your app?
    This is for initial login and their acceptance of connecting our application to their dropbox account. After that i want it to store their dropbox account details and perform backups of the database without them having to enter their details again

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