Automatic login script for Web Browser session

Version 1

    Verified Product Versions

    Wavelink Naurtech CETerm 5.7

    This script is provided as a sample for automatic login to a web based application. You MUST edit this script to satisfy the web application requirements.

     

    Here are the things that you will need to modify prior to running this script:

     

    Determine the title of the login web page

    Determine the HTML elements on the login page that must be populated for username and password

    Actual values for username and password

    Submit the form

    You must load this script into CETerm and check the "Load at Startup" option.

     

    The script implements a OnDocumentDone event handler. This is called everytime a web page is successfully loaded. It validates the title of the page to check if this is the "login" page. If this is the correct login page, the script uses the DOM (Document Object Model) to identify the form elements associated with the username and password and sets these values. It then submits the form.

     

    Please review the TODO comments in the script and edit it to satisfy your web application environment.

     

    /*OnDocumentDone*/

    function OnDocumentDone( session )

    {

        var document = CETerm.Session( session ).Browser.Document;

        var title = document.title;

     

        // TIP: Uncomment the following line to determine the title

        //OS.Alert("document title=" + title);

     

       // TIP: You can also use "document.URL" to identify your login page

        var mylogintitle = "TODO: enter your login title here";

     

        if (title.match( mylogintitle ))

        {

            // TODO: Set login elements

            // TODO: Edit the following to correspond to your HTML login page

            // TODO: Set the form name, element, and content

     

            // document.forms[0].user.value = "joeuser";

     

            // document.forms[0].password.value = "secretpassword";

     

            // TODO: Fill in any additional fields

            // document.forms[0].department.value = "shipping";

     

            // Submit the form

            // TODO: Edit the following to specify the correct form name.

            // document.forms[0].submit();

        }

     

    }