CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2011
    Posts
    1

    [RESOLVED] Auto Login to webpage running javascript

    I am new to programming and trying to create an application to login to a website and download a report automatically. I am stuck at the login part .

    What i have so far:

    Public Class Main

    Private Property HtmlDocument As HtmlDocument

    Private Property InptElmt As Object

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    WebBrowser1.Navigate("https://secure-ausomxjna.crmondemand.com/OnDemand/user/ReportIFrameView?SAWDetailViewURL=saw.dll?Go%26Path%3D%252fusers%252fvertafore%2523bbardorf%252fAll%2bOpen%2b-%2bFinancePro&AnalyticReportName=All+Open+-+FinancePro")
    'Dim webbrowser1.navigate "https://secure-ausomxjna.crmondemand.com/OnDemand/user/ReportIFrameView?SAWDetailViewURL=saw.dll?Go%26Path%3D%252fusers%252fvertafore%2523bbardorf%252fAll%2bOpen%2b-%2bFinancePro&AnalyticReportName=All+Open+-+FinancePro"

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    WebBrowser1.Document.GetElementById("j_username").SetAttribute("value", TextBox1.Text)
    WebBrowser1.Document.GetElementById("j_password").SetAttribute("value", TextBox2.Text)

    The problem is i cannot hit the sumbit button. It is actually not a button by a link that is hidden and calls a javascript function

    The code on the site looks like the following:

    <td></td>
    <td style="padding-right:1px"><table border="0" width="300px" cellpadding="0" cellspacing="0"><tr><td style="width:22px"><input name="rememberMe" type="checkbox" checked="checked" onkeypress="return checkEnterLogon(event);" /></td>
    <td class="logonFont">Remember My User ID</td>
    <td align="right"><table border="0" cellpadding="0" cellspacing="0"><tr>
    <td onmouseout="if(className!='disableLogonScreenButtonTD'){ className='logonScreenButtonTD'};;" onmouseover="if(className!='disableLogonScreenButtonTD'){ className='logonScreenButtonTD-inv'};;" class="logonScreenButtonTD" onclick="className='disableLogonScreenButtonTD';;">
    <a href="javascript:void(0)" class="loginLink" onclick="checkPreSubmit (document.logonForm); return false;" onkeypress="return checkEnterLogon(event);">Sign In</a></td></tr></table></td></tr></table></td></tr></table>
    <input name="redirect" type="hidden" value="$5$YElWh/hfwDFQKCUEpBnulvezB4CpfBGUv8pa6/qHEYhSDWbAc=;$5$8Oime/ECOdniC7kDRnyTaScOsTQ94KhlK7xpATL0jY+5K2TDAM8Y6CGQu4o4xttAmME+mNe1fenDw6oVIr7LNqoO+bHQ1H1+ThpBMxJmPQUrEb+fQO+T4VomJHxlRWgynWhEh0Ns0yTX+aqw/yjXpwmskqhSeg6BuQ0wJ1PFFd1tVIZ3KnsJLicXYxJpoZVdAidn9C1NhXodXZ7DScWuP/peu3u55Ct7u0FAB2boIR9I5AVLTYyDEwLnfeF+X38AfWssqOCJigIAur+3pmBMWPui2y8obMWKcj/xDLj3g83Dlq2uvdG4fKF+aq84EXTjOZHbMKRXrOaByQRrmF7rX9BDJylQ==" /><input name="langCode" type="hidden" value="enu" /></form></td></tr><tr><td style="padding-top:8px" align="center"><form name="forgotPwdForm" action="ForgotPassword" method="post"><table><tr><td>
    <a href="javascript:void(0)" class="forgotPasswd" onclick="forgotPassword();return false;">Forgot Your Password?</a></td></tr></table><input name="j_username" type="hidden" /><input name="lang" type="hidden" value="enu" /></form></td></tr></table></center>
    </td>

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Auto Login to webpage running javascript

    Many sites don't allow logging in remotely. Also, code could be used for malicious purposes, if we post it in the wild
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

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

Featured