Your e-Business Quality Partner eValid™ -- The Web Quality Suite
Browser-Based Client-Side Functional Testing and Validation Page Timing/Tuning Transaction Monitoring. WebSite Spidering & Analysis and Realistic Server Loading.

eValid -- eValid Programmatic Interface (EPI) -- Example Program #07
eValid Home

Example Program #07
This program illustrates the eValid EPI interface by implementing PARTIALLY (top and bottom actions only), entirely in CPP, the script-based Gmail Example which is done entirely with index commands.

The program invocation would be as follows (there are no arguments): example07.exe

Program Source
Here is the CPP for the EPI program for this example. The EPI program generates the complete event log, similar to other EPI examples in this set.



#include "stdafx.h"
#include "epi.h"
using namespace std;

void TraceEvalidLog(IEvalid * p)
{
    if (p == NULL) return;
    IEvalidLogCollection * pColl;
    if (SUCCEEDED(p->get_LastPlaybackLog(&pColl)))
    {
        long numItems;
        pColl->get_length(&numItems);
        for(long i = 0; i < numItems; ++i)
        {
            IEvalidLog * pLog;
            pColl->item(i, &pLog);

            long seq, cmd, line, a, f, t;
            CComBSTR date, time, prj, grp, tst, stat, msg;

            pLog->get_accumTime(&a);
            pLog->get_cmdNum(&cmd);
            pLog->get_date(&date);
            pLog->get_fineTime(&f);
            pLog->get_groupName(&grp);
            pLog->get_lineNum(&line);
            pLog->get_message(&msg);
            pLog->get_projectName(&prj);
            pLog->get_seqNum(&seq);
            pLog->get_status(&stat);
            pLog->get_testName(&tst);
            pLog->get_time(&time);
            pLog->get_totalCmdTime(&t);
           
            pLog->Release();

            cout <<    CString(date) << " " << CString(time)
                << "\t" << seq << "\t" << cmd << "\t" << line
                << "\t" << CString(prj) << "\t" << CString(grp)
                << "\t" << CString(tst) << "\t" << CString(stat)
                << "\t" << a << "\t" << f << "\t" << t
                << "\t" << CString(msg) << endl;
        }
        pColl->Release();
    }
}
int main()
{
    long index;
    ::CoInitialize(NULL);

    IEvalid * pEvalid = NULL;
    HRESULT hr = CoCreateInstance(CLSID_Evalid, NULL,
            CLSCTX_INPROC_SERVER, IID_IEvalid, (void**)&pEvalid);

    if (SUCCEEDED(hr))
    {
// ----------------------------------------------------------------------------
// Step 1: Start at www.google.com, then navigate to gmail and log in...
// Natural timings remain in script here.  The password is encrypted.

        pEvalid->InitLink(CComBSTR("http://www.google.com"));
        TraceEvalidLog(pEvalid);

        pEvalid->Wait(5016);
        TraceEvalidLog(pEvalid);

		pEvalid->IndexSet(0);
        TraceEvalidLog(pEvalid);

		pEvalid->IndexFindElement(0, CComBSTR("DOWN"), CComBSTR("innerText"), 
	    CComBSTR("Gmail"), CComBSTR(""), &index);
        TraceEvalidLog(pEvalid);

	pEvalid->IndexMove(+2);
        TraceEvalidLog(pEvalid);

        pEvalid->IndexFollowLink(0, NULL);
        TraceEvalidLog(pEvalid);

        pEvalid->Wait(2079);
        TraceEvalidLog(pEvalid);

        pEvalid->SyncOnText( 0, CComBSTR("Username"), 
		CComBSTR(""));
        TraceEvalidLog(pEvalid);

        pEvalid->Wait(2516);
        TraceEvalidLog(pEvalid);
	
		pEvalid->IndexSet(0);
        TraceEvalidLog(pEvalid);

		pEvalid->IndexFindElement(0, CComBSTR("DOWN"), CComBSTR("id"), 
	    CComBSTR("Email"), CComBSTR(""), &index);
        TraceEvalidLog(pEvalid);

        pEvalid->IndexInputValue(0, CComBSTR("TEXT"), CComBSTR("evalidinc"), 
	    CComBSTR(""), NULL);
        TraceEvalidLog(pEvalid);

        pEvalid->Wait(2542);
        TraceEvalidLog(pEvalid);

		pEvalid->IndexFindElement(0, CComBSTR("DOWN"), CComBSTR("id"), 
	    CComBSTR("Passwd"), CComBSTR(""), &index);
        TraceEvalidLog(pEvalid);

        pEvalid->IndexInputValue(0, CComBSTR("TEXT"), CComBSTR("«p°㮉»"), 
	    CComBSTR(""), NULL);
        TraceEvalidLog(pEvalid);

        pEvalid->Wait(171);
        TraceEvalidLog(pEvalid);

		pEvalid->IndexFindElement(0, CComBSTR("DOWN"), CComBSTR("name"), 
	    CComBSTR("signIn"), CComBSTR(""), &index);
        TraceEvalidLog(pEvalid);

        pEvalid->IndexSubmitClick(0, CComBSTR(""));
        TraceEvalidLog(pEvalid);

        pEvalid->Wait(213);
        TraceEvalidLog(pEvalid);

		pEvalid->Reload(0);
        TraceEvalidLog(pEvalid);

        pEvalid->SyncOnText( 0, CComBSTR("Sign out"), 
			CComBSTR("number:3"));
        TraceEvalidLog(pEvalid);

        pEvalid->Wait(2099);
        TraceEvalidLog(pEvalid);

        pEvalid->SyncOnText( 0, CComBSTR("Set status here"), 
		CComBSTR("number:3"));
        TraceEvalidLog(pEvalid);

        pEvalid->Wait(1814);
        TraceEvalidLog(pEvalid);


// ---------------------------------------------------------------------
// Step 2: Sign out and wait (synchronize) until you're ready to sign
//	in again...

	pEvalid->Wait(3275);
        TraceEvalidLog(pEvalid);

	pEvalid->FollowLink(0, 99, CComBSTR("evalidinc@gmail.com"), 
	CComBSTR("https://google.com/profiles"), CComBSTR("number:3"));
        TraceEvalidLog(pEvalid);

        pEvalid->Wait(6720);
        TraceEvalidLog(pEvalid);

	pEvalid->FollowLink(0, 123, CComBSTR("Sign out"), 
	CComBSTR("https://mail.google.com/mail/?logout&hl=en"), CComBSTR("number:3"));
        TraceEvalidLog(pEvalid);

	pEvalid->Wait(1872);
        TraceEvalidLog(pEvalid);

        pEvalid->SyncOnText( 0, CComBSTR("Sign in"), CComBSTR(""));
        TraceEvalidLog(pEvalid);

//  Note: Playback involves adaptive playback, so there will be Messages in the
//	event log and you probably will see a "Yellow screen", unless the GMAIL
//	application itself generated a server side internal navigation error to document...
// Script ends.


        pEvalid->ExitNow();
// ----------------------------------------------------------------------------
        pEvalid->Release();
    }
    else
    if (hr == E_ACCESSDENIED)
        cout << "Missing a valid EPI license key!" << endl;
    else
        cout << "Unable to load EPI!" << endl;

    ::CoUninitialize();

    return 0;
}
  
 

Resources

  1. You can try this example out yourself on Windows machines: example07.evs.

  2. You can compile this program locally from the CPP source: example07.cpp.

  3. Here is the compiled CPP program that you can run locally: example07.exe.

Corresponding eValid Script
Here is the corresponding eValid recorded script.


# (c) Copyright 2012 by Software Research, Inc. 
# Recording made on: Microsoft Windows XP 
#
# NOTE: This script design to only playback successfully with IE 7.0...

ProjectID "FunctionalTests"
GroupID "Experimental"
TestID "example07"
LogID "AUTO"

ScreenSize 1280 1024
FontSize 0
DeleteCache
DeleteCookies
DeleteSession

# ---------------------------------------------------------------------
# Step 1: Start at www.google.com, then navigate to gmail and log in...
#	Natural timings remain in script here.  The password is encrypted.

InitLink "http://www.google.com/"
Wait 5016
IndexSet 0
IndexFindElement 0 DOWN "innerText" "Gmail" ""
IndexMove +2
IndexFollowLink 0 ""
Wait 2079
SyncOnText 0 "Username" ""
Wait 2516
IndexSet 0
IndexFindElement 0 DOWN "id" "Email" ""
IndexInputValue 0 "TEXT" "evalidinc" "" ""
Wait 2542
IndexFindElement 0 DOWN "id" "Passwd" ""
IndexInputValue 0 "TEXT" "?p?㮉»" "" ""
Wait 171
IndexFindElement 0 DOWN "name" "signIn" ""
IndexSubmitClick 0 ""
Wait 2213
SyncOnText 0 "Sign out" "number:3"
Wait 2099
SyncOnText 0 "Set status here" "number:3"
Wait 1814


# ---------------------------------------------------------------------
# Step 2: Sign out and wait (synchronize) until you're ready to sign
#	in again...

Wait 3275
FollowLink 0 99 "evalidinc@gmail.com" "https://google.com/profiles" "number:3"
Wait 6720
FollowLink 0 123 "Sign out" "https://mail.google.com/mail/?logout&hl=en" "number:3"
Wait 1872
SyncOnText 0 "Sign in" ""

# Note: Playback involves adaptive playback, so there will be Messages in the
#	event log and you probably will see a "Yellow screen", unless the GMAIL
#       application itself generated a server side internal navigation error to
#       document...

# Script ends.