Logging into a webpage

I’ve written scripts to login to webpages before, but I’m having a problem with a particular page. When I click the login button through my script, I receive an error message that “We cannot log you in at this time.”

Logging in manually works fine. I’m sure it’s my own lack of knowledge but I just can’t seem to find what might be causing the login process to get handled differently.

I’ll try to provide enough detail here without dumping a thousand lines of code.

Here is the source for the login button:

<table id="memberloginbtn" border="0" cellspacing="0" cellpadding="0" width="100%" class="columns" style="color:#4A4A4A;"> <tr> <td id="tdLogonCell" class="lnkSmall"><input type="submit" name="_ctl0$MainContentPlaceHolder$oSession$oLogon" value="" id="oLogon" tabindex="3" class="btn yellow-custom" data-i18n="[value]LoginPage.Login" /></td> </tr> </table> <div class="howtojoin"><table id="memberloginasst" border="0" cellspacing="0" cellpadding="0" class="columns" style="color:#4A4A4A;"> 

and here is my script:

#Open Page $IE=new-object -com internetexplorer.application $IE.navigate2("https://somepage.aspx") $IE.visible=$True #Enter Username $Doc = $IE.Document $Username = <username> $UsernameField= $Doc.getElementById('oUserID') $UsernameField.Value = "$Username" #Enter Password $Pswd = <password> $PswdField= $Doc.getElementById('txtPlainPassword') $PswdField.Value = "$Pswd" #Login $LoginButton = $Doc.getElementById('oLogon') $LoginButton.setActive() $LoginButton.Click() while ($ie.busy -eq $true){ start-sleep -milliseconds 1000} $ie.document.documentelement.innertext |out-file C:Dump.txt 

When I run this, I see each field properly filled, then see the login button get clicked. However, that’s when I get the error that I can’t be logged in.

submitted by /u/badtasteic
[link] [comments]

Leave a Reply