|
-
May 5th, 2013, 11:47 PM
#1
Thread Starter
New Member
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
-
May 6th, 2013, 10:19 AM
#2
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
-
May 6th, 2013, 10:42 AM
#3
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"
-
May 6th, 2013, 02:38 PM
#4
Thread Starter
New Member
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
-
May 6th, 2013, 02:45 PM
#5
Thread Starter
New Member
Re: login code for dropbox not working. desperate for help
 Originally Posted by Static
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|