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

Example Program #06
This program illustrates the eValid EPI interface putElementProperty command that puts values into the DOM using the eValid browser.

The example program is set up as a to accept these arguments:

  1. URL is the url to be analyzed.
  2. IDX is the internal HTML element number (sourceIndex) assigned by eValid.
  3. NAME is the property/attribute to be searched for.
  4. VALUE is the value to be inserted.

The program invocation would be as follows: example06.exe URL IDX NAME VALUE

For example, a run.bat containing something like:

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 < 5)
    {
        cout << "Syntax: example06.exe \"url\" idx \"name\" \"value\"" << endl;
        return 1;
    }
    LPCTSTR lpszUrl = argv[1];
    long index = _tstol(argv[2]);
    LPCTSTR lpszName = argv[3];
    LPCTSTR lpszValue = argv[4];

    ::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)))
        {
            if (index < 0 || index >= numItems)
            cout << "index is out of bounds" << endl;
            else
            pEvalid->put_ElementAttribute(0, index, 
                CComBSTR(lpszName), CComBSTR(lpszValue), NULL);
        }

        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: example06.cpp.

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