dcsimg
Results 1 to 5 of 5
  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2018
    Posts
    2

    Resolved [RESOLVED] signing into gmail with Visual Basic

    What I'm trying to accomplish here is to be able to log into my gmail account using a string of code when a button is clicked. Google prompts for the username first then you have to click next. Here is my code for this part.

    Code:
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
            WebBrowser1.Document.GetElementById("identifierId").SetAttribute("value", "email address")
            WebBrowser1.Document.GetElementById("identifierNext").InvokeMember("Click")
        End If
    End Sub
    I'm getting an error when trying to do this with gmail, but it does not show up when I edit the element by id fields and try it on facebook. What am I doing wrong?

    Name:  my error.jpg
Views: 167
Size:  20.7 KB

  2. #2
    Fanatic Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    773

    Re: signing into gmail with Visual Basic

    The simplest answer is "you are trying to automate a web page", a slightly longer answer is "you are trying to automate a web page that isn't designed to be automated and there is a supported API way of accessing gmail" - https://developers.google.com/gmail/api/

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    32,011

    Re: signing into gmail with Visual Basic

    If there is an API, use the API. Web pages change often. Web designers seem to take particular, even perverse, pleasure in redesigning pages to suit a whim. Therefore, even if you could get this to work tomorrow, it would be likely to break the next day. The whole point behind an API is to give you a stable target that programs will work with reliably rather than an unstable target that will always be slower.
    My usual boring signature: Nothing

  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2018
    Posts
    2

    Re: signing into gmail with Visual Basic

    Thank you. I appreciate the prompt responses.

  5. #5
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,023

    Re: [RESOLVED] signing into gmail with Visual Basic

    A WB is a UI control. If you are not using it as such then don't.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width