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 #08
eValid Home

Example Program #08
This program illustrates the eValid EPI interface by implementing, entirely in CPP, it is a variant of one of our script-based "mapslive.evs" which is done entirely with index commands.

The program invocation would be as follows (there are no arguments): example08.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.


// FileName: Example08.cpp

#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()
{
    ::CoInitialize(NULL);

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

    if (SUCCEEDED(hr))
    {
// ----------------------------------------------------------------------------
// Step 1: Step 1: Startup...
        pEvalid->InitLink(CComBSTR("http://www.virtualearth.com"));
        TraceEvalidLog(pEvalid);

// Step 2: To assure page is ready (AJAX) replace Wait with DOM Sync...
        pEvalid->SyncOnSelectedObjProperty(0, 415, CComBSTR("className"), CComBSTR("fg"), 
	CComBSTR("readyState"), CComBSTR("complete"), CComBSTR(""));
        TraceEvalidLog(pEvalid);

// Step 3: Make the search request...
        pEvalid->InputValue(0, 100, CComBSTR("TEXT"), CComBSTR("sb_form_q"), 
	    CComBSTR("q"), CComBSTR("Moscone Conven" \
	"tion Center San Francisco, CA"), CComBSTR(""), CComBSTR(""));
        TraceEvalidLog(pEvalid);

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

        pEvalid->SubmitClick(0, 103, CComBSTR("sb_form_go"), CComBSTR("go"), 
	    CComBSTR(""), CComBSTR(""));
        TraceEvalidLog(pEvalid);

// Step 4: To assure results have arrived, replace Wait with URL Sync...
        pEvalid->SyncOnURL(CComBSTR("http://maps.live.com/BrandFinder.ashx"));
        TraceEvalidLog(pEvalid);

// Step 5: Validate text is found...
        pEvalid->ValidateSelectedText(0, 356, 0, 
	    CComBSTR("747 Howard St,"), CComBSTR(""));
        TraceEvalidLog(pEvalid);

// Step 6:
        pEvalid->Wait(3946);
        TraceEvalidLog(pEvalid);

        pEvalid->SyncOnSelectedObjProperty(0, 207, CComBSTR("id"), 
	CComBSTR("YN114x2001180_number"), CComBSTR("nameProp"), CComBSTR("#"), CComBSTR(""));
        TraceEvalidLog(pEvalid);

// Step 7:
	pEvalid->Wait(2387);
        TraceEvalidLog(pEvalid);
        pEvalid->MatchString( 0, CComBSTR("(415) 974-4000"), 0, CComBSTR(""));
        TraceEvalidLog(pEvalid);

// End of script.


        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: example08.evs.

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

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

Corresponding eValid Script
Here is the corresponding eValid recorded script "example08.evs":


# Recording by eValid V9
# (c) Copyright 2012 by Software Research, Inc. 
# Recording made on: Microsoft Windows Vista (IE 7.0.6000.16643)

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

ScreenSize 1440 900
FontSize 0
DeleteCache
DeleteCookies

# Step 1: Startup...
InitLink "http://www.virtualearth.com/"

# Step 2: To assure page is ready (AJAX) replace Wait with DOM Sync...
# Wait 19407
SyncOnSelectedObjProperty 0 415 "className" "fg" "readyState" "complete" ""

# Step 3: Make the search request...
InputValue 0 100 "TEXT" "sb_form_q" "q" "Moscone Conven" \
	"tion Center San Francisco, CA" "" ""
Wait 374
SubmitClick 0 103 "sb_form_go" "go" "" ""

# Step 4: To assure results have arrived, replace Wait with URL Sync...
# Wait 17902
SyncOnURL "http://maps.live.com/BrandFinder.ashx"

# Step 5: Validate text is found...
ValidateSelectedText 0 356 0 "747 Howard St," ""

# Step 6:  
Wait 3946
SyncOnSelectedObjProperty 0 207 "id" "YN114x2001180_number" "nameProp" "#" ""

# Step 7:  
Wait 2387
MatchString 0 "(415) 974-4000" 0

# End of script.