VBS Script getElementbyID Error (AutoLogin Script)

I am writing .vbs script file which works for different sites, but I am writing auto login script for my university web page for internet page login.

So I have working til where it fills out username and password but I can't get it to click login.

Here is link to university login. I am not sure that you can access it from out of network.

(Note editors plz dont make it live link)

hxxps://wlc-airrowdy1.utsa.edu/fs/customwebauth/studentlogin.html

Here is my script code.

WScript.Quit Main

Function Main
    Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_")
    IE.Visible = True
    IE.Navigate "https://wlc-airrowdy1.utsa.edu/fs/customwebauth/studentlogin.html"

    Wait IE
    WScript.Echo "This is WSH version", WScript.Version

    With IE.Document
        .getElementByID("username").value = "myuser"
        .getElementByID("password").value = "mypass"
        .getElementByID("top").submitAction
    End With
End Function

Sub Wait(IE)
    Do
        WScript.Sleep 500
    Loop While IE.ReadyState < 4 And IE.Busy 

    Do
        WScript.Sleep 500
    Loop While IE.ReadyState < 4 And IE.Busy 
End Sub

Sub IE_OnQuit
    On Error Resume Next
    WScript.StdErr.WriteLine "IE closed before script finished."
    WScript.Quit
End Sub

Here is sourcecode for page if you can't access link above.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="EN" xml:lang="EN">
<head>

<title>UTSA: AIR Rowdy Wireless Network - The University of Texas at San Antonio</title>
<meta content=no-cache http-equiv=Cache-control />
<meta content=no-cache http-equiv=Pragma />
<meta content=-1 http-equiv=Expires />
<meta http-equiv="Content-Language" content="EN" />
<meta content="text/html; charset=iso-8859-1" http-equiv=Content-Type />
<meta name="author" content="UTSA IT: Christopher Chipps" />
<meta name="robots" content="none" />
<meta name="MSSmartTagsPreventParsing" content="true" />
<meta name="Description" content="The AIRowdy Guest wireless Internet access page." />
<meta name="Keywords" content="UTSA OIT, OIT, The Office of Information Technology, Department IT, Department Software, Help Desk" />
<meta name=GENERATOR content="MSHTML 8.00.7600.16535" />

<link rel="shortcut icon" href="http://www.utsa.edu/oit/favicon.ico" />
<link href="3col.css" type="text/css" rel="stylesheet" />

<SCRIPT language="javascript" type="text/javascript" src="./loginscript.js"></SCRIPT>

<SCRIPT language="javascript" type="text/javascript">
    var url = "";
    if(url != ""){
        var link = document.location.href;
        var searchString = "?redirect=";
        var equalIndex = link.indexOf(searchString);
        var redirectUrl = "";
        if(equalIndex > 0) {
                equalIndex += searchString.length;
                redirectUrl += link.substring(equalIndex);
                //attach the redirect url only if the ext web auth url doesn't contain it
                searchString = "&redirect=";
                equalIndex = url.indexOf(searchString);
                if(equalIndex < 0){
                    url+= "&redirect=";
                    url+=redirectUrl;
                }
        }
        window.location.href = url;
    }
</SCRIPT>
</head>
    <body>
       <div class="h"><a href="#content">Skip to main content</a></div>
        <table id="bodytable" align="center" cellpadding="0" cellspacing="0">
            <tr>
                <td id="banner1">   
                   <img src="utsaicon2c.gif" alt="UTSA The University of Texas at San Antonio" /></td>
            </tr>
            <tr>
                <td id="banner2">
                    <ul id="mainnav">
                        <li>&nbsp;</li>
                    </ul></td>
          </tr>
            <tr>
                <!-- keep the td tags in one line or else you will have a gap in IE -->              
                <td id="leftcontent">
                  <h1><a name="content"></a>Welcome to AirRowdy</h1>
                  <FORM method=post action="/login.html">
                  <INPUT value=0 maxLength=15 size=16 type=hidden name=buttonClicked />
                  <INPUT value=0 maxLength=15 size=16 type=hidden name=err_flag />
                  <INPUT maxLength=31 size=32 type=hidden name=err_msg />
                  <INPUT value=0 maxLength=15 size=16 type=hidden name=info_flag />
                  <INPUT maxLength=31 size=32 type=hidden name=info_msg />
                  <INPUT maxLength=255 size=255 type=hidden name=redirect_url /> 

                  <table width="100%" border="0" cellpadding="0" cellspacing="10" class="border_padding">
                    <tr>
                      <td colspan="2" valign="top"><h2>Student Login</h2></td>
                      <td width="48%" rowspan="4" align="right" valign="top"><img src="AirRowdy1.gif" alt="Welcome to AirRowdy" width="244" height="155" border="0" /></td>
                    </tr><script language="javascript" type="text/javascript">getErrorMsgIfAny();</script>                    
                    <tr>
                      <td width="21%"><label for="username"><b>myUTSA ID (abc123)</b></label></td>
                      <td width="31%"><input type="text" maxlength=63 size=25 name=username /></td>
                    </tr>

                    <tr>
                      <td><label for="password"><b>Password</b></label></td>
                      <td><input onkeypress=submitOnEnter(event); maxlength=63 size=25 type=password name=password emweb_type="PASSWORD" autocomplete="off" /></td>
                    </tr>
                    <tr>
                      <td>&nbsp;</td>
                      <td><script language="javascript" type="text/javascript">getHtmlForButton("Submit","Login","button","submitAction()"); setDisabledBtn();</script></td>
                    </tr>
                  </table>
                  </FORM>
                  <p>AirRowdy is UTSA's wireless network. It is available from any building at UTSA (Main Campus, Downtown Campus and The Institute of Texan Cultures).</p>
                  <p>Log on to AirRowdy with 
                  your UTSA ID (abc123) and password.</p>
                  <p>Logged-in users can 
                  reach the Internet, access e-mail and print at one of UTSA's Print Spots on campus.</p>
                  <h3>Usage 
                    Policy</h3>
                  <p>Use of the campus wireless network is governed by the <abbr title="The University of Texas at San Antonio" lang="en" xml:lang="en">UTSA</abbr> Information Resources Use and Security Policy (http://www.utsa.edu/hop/chapter8/8-12.cfm). By connecting to this network, you agree to abide by university policies   regarding appropriate computer usage. &nbsp;</p>
                  <h3>About AirRowdy</h3>
<!--                  <p>To ensure connectivity 
                    you should purchase a wireless network card that is 802.11b or 
                    802.11g (Wi-Fi) compliant.&nbsp; A web browser which supports SSL 
                    and Javascript is also required.&nbsp; No configuration changes are 
                    necessary once your wireless card is installed and functioning 
                    correctly. All web traffic (HTTP, HTTPS, etc.) is allowed on the 
                    wireless network.</p>-->
<!--                  <p>You should connect to AIR Rowdy using a wireless network card that is 802.11b or 
                    802.11g (Wi-Fi) compliant.&nbsp; A web browser which supports SSL 
                    and Javascript is also required.&nbsp; No configuration changes are 
                    necessary once your wireless card is installed and functioning 
                    correctly. All web traffic (HTTP, HTTPS, etc.) is allowed on the 
                    wireless network.</p>-->
                  <p>As a general rule, 
                    traffic on wireless networks, including AirRowdy, is <i><b>not</b></i> encrypted. This means  there is a risk of 
                    having your session &quot;sniffed&quot; during transmission.&nbsp; If you plan 
                    on entering sensitive information (passwords, credit card numbers) 
                    on a website, ensure  the site is SSL-encrypted - the URL 
                    should start with http<strong><i>s</i></strong> (not http)&nbsp; and 
                    you should see a &quot;lock&quot; icon in your browser's status 
                    bar.</p>
                  <h3>AirRowdy 
                    Help</h3>
                  <p><b>Students</b>: To activate 
                    your UTSA ID, or if you are experiencing connection issues with 
                    AirRowdy, please visit one of the Student Computing Services Labs 
                    during regular hours for assistance.</p>
                  <p>- BB 2.01.20 (Main Campus)<br />
                    - FS 2.400 (Downtown 
                  Campus)<br />
              - Library JPL  Information Commons              </p>              </td>
          </tr>

                <tr>
                    <td id="footer">
                        <div id="bottomNav"> <strong>&copy; The University of Texas at San Antonio, One UTSA Circle, San Antonio, TX 78249-1644, (210) 458-4011</strong></div></td>
                </tr>
                <tr>
                    <td id="credit">Designed &amp; Maintained by The Office of Information Technology &#8212; Last update:
                   <!-- #BeginDate format:Am1 -->August 12, 2010<!-- #EndDate -->-></td>
                </tr>
        </table>
</body>
</html>

Answers:

Answer

I'm not sure a form element has a member method called submitAction. Should it be simply submit?

And I don't see any elements with the IDs you're looking for: "username", "password" or "top"

With IE.Document
    .getElementByID("username").value = "myuser"
    .getElementByID("password").value = "mypass"
    .getElementByID("top").submitAction
End With

I'm guessing you're looking for eg

<td width="31%"><input type="text" maxlength=63 size=25 name=username /></td>

where you would use getElementsByName, which returns an array of elements

dim elements: set elements = document.getElementsByName("username")
elements(0).Value = "username"

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.