Script not allowing to auto-login to a website

This topic contains 7 replies, has 5 voices, and was last updated by  Joe Maruca 2 months, 1 week ago.

  • Author
    Posts
  • #95645

    Joe Maruca
    Participant

    Hello folks,
    I am trying to write a script that allows an auto-login to a website, for example LinkedIn.com, when you run the script, you can see the Username/Password being entered, but then stops; i.e. does not login to the site. Please see the code below, is anyone able to advise where I am going wrong?, many thanks.

    $username = "enter username here"
    $password = "enter password here"
    $ie = New-Object -com InternetExplorer.Application
    $ie.visible = $True
    $ie.navigate("https://www.linkedin.com")
    while($ie.ReadyState -ne 4) {start-sleep -seconds 3}
    $ie.document.getElementById("login-email").value= "$username"
    $ie.document.getElementById("login-password").value = "$password"
    $final_login = $ie.document.getElementById('login-submit')
    $final_login.click()
    start-sleep 3

  • #95648

    Don Jones
    Keymaster

    A lot of websites have implemented code to stop this from working, because they deal with so many malicious bots. In those cases, there's not much you can do.

    • #95685

      Joe Maruca
      Participant

      Hi Don,
      That makes very good sense; I was very focussed to making it work but did not come to the realization that the website could see the auto-login as potentially malicious, thank you for that.

  • #95663

    Patrick Chambers
    Participant

    If I'm using the code to test the site's availability, can I set the website to allow connections from a defined source? I've been trying to learn enough Linux to deploy a Xymon monitoring server, but I keep thinking that there has to be a way to do it with PS instead.

    Thanks,
    Patrick

  • #95714

    postanote
    Participant

    They indeed block this auto-logon on the landing page.

    That 'Sign in'/'Login', button is really not a button at all. You can see that by walking the form object element and other page elements. No matter how you try to hit it, by id, name, tag, class, etc. It will fail.

    If you look at the page / element source. It's one of that has a disabled element.

    input tabindex="1" disabled="" class="login submit-button" id="login-submit" type="submit" value="Sign in"

    • #95720

      Patrick Chambers
      Participant

      Thanks, postanote. Now I know what I'm looking at, but you and Don have a point, it's too general to risk. I'll find a way to test that the conditions for logging in are present instead.

      Thanks!
      Patrick

  • #95781

    Francis Paul
    Participant

    Hello Joe,

    The element is indeed disabled, but it is possible to just enable this.

    Just add the below line before the $final_login.click()

    $final_login.disabled = $False

    Thanks,
    Francis.

    • #95786

      Joe Maruca
      Participant

      Hi Francis,
      Excellent, that worked very nicely!, thank you very much for that.

You must be logged in to reply to this topic.