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

Example Program #05
This program illustrates the eValid EPI interface getElementProperty command that accesses the DOM within the eValid browser. The example program is set up to accept three arguments:

A typical invocation would be as follows: example05.exe URL NAME VALUE

For example, a run.bat containing something like:

The program is intended to behave in the following way: On the specified URL this program will search through all of the elements on the page and print out each one where there is property with NAME, and stop on the first property with NAME = VALUE.

Program Source
Here is the CPP for the EPI program for this requirement.

#include "epi.h"

using namespace std;

int main(int argc, TCHAR* argv[], TCHAR* envp[])
{
    if (argc < 4)
    {
        cout << "Syntax: example05.exe URL NAME VALUE" << endl;
        return 1;
    }

    LPCTSTR lpszUrl = argv[1];
    LPCTSTR lpszName = argv[2];
    LPCTSTR lpszValue = argv[3];

    ::CoInitialize(NULL);

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

    {
        pEvalid->InitLink(CComBSTR(lpszUrl));

        long numItems;
        if( SUCCEEDED(pEvalid->get_NumElements(0, NULL, &numItems)))
        {
            for (int i = 0; i < numItems; ++i)
            {
                CComBSTR bstrValue;
                pEvalid->get_ElementProperty(0, i, 
                    CComBSTR(lpszName), NULL, &bstrValue);
                if (bstrValue == lpszValue)
                {
                    cout << "Found element at index " << i << endl;
                    break;
                }
            }
        }
        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 compile this program locally from the CPP source: example05.cpp.

  2. Here is the compiled CPP program that you can run locally: example05.exe.