|
TSMFCAPI Class and Method Definitions
//Exception classes
//==============================================================================
/*
* UninitializedException
* Thrown when a call is made to any (other) method prior to calling InitSession
*/
class UninitializedException
{
public:
CString reason;
UninitializedException(CString why) : reason(why) {}
};
/*
* InSessionException
* Thrown when a second call is made to InitSession, before ExitSession is called
*/
class InSessionException
{
public:
CString reason;
InSessionException(CString why) : reason(why) {}
};
//==============================================================================
/*
* The MFCSmith class contains methods to interface with TestSmith
* via the TSAPI shared library. These methods allow the TestSmith
* Playback Engine to be driven by a C++ program.
* The other methods of this class are for controlling and managing this access.
* It is recommended that the playback automation is driven by these
* methods, while the logic, control and storage of information is handled
* by the C++ program itself.
* Override this class to create a TestSmith test.
* See the example tests:
YahooLogin.cpp
and
DataDriver.cpp
*/
class MFCSmith
{
public:
/* constructor */
MFCSmith();
/* destructor */
virtual ~MFCSmith();
/*
* Main entry point to run a MFCSmith Session.
* This method must be overidden by any class that extends MFCSmith.
* $param data: a formatted string containing the data that is required to
* run the session. The format of the string will be specific
* to each test, as appropriate.
* $return: tester-defined value (usually the error code from the test)
*/
virtual int Run(CString data = EMPTY) = 0;
/* Representation of an empty String */
static const CString EMPTY;
/* Representation of a single space character */
static const CString SPACE;
/* The value 0 (zero) */
static const int NO_ERR;
/*
* Display the most recent report in a browser window.
* The browser used will be the one specified under the sInternetBrowser
* setting in the /QualityForge/TestSmith/System/testsmith.settings file.
* Note:
* This method may be called at any time during or after a session.
* Because this method is static it will display the most recent report
* created by this or any other MFCSmith object. No error message is
* generated when a report is not found.
* $return: 0 (FALSE) if no recent report exists, otherwise 1 (TRUE).
*/
static int DisplayLastReport();
protected:
/* Initialize the TestSmith Playback Engine.
* This method must be called before any of the command methods are called.
* $param report_name: the name of the report to be created.
* This can be a short name, a relative path or a full path.
* It should /not/ contain any extension.
* If no report is required leave this parameter empty or use 0 (zero)
* $return: 1 (TRUE) for success, 0 (FALSE) for failure
* $throws: InSessionException
* $href: reports.html
*/
int InitSession(CString report_name = 0);
/*
* Exit from the TestSmith Playback Engine.
* This call performs object destruction in the TSAPI library.
* It should always be called after all commands have executed in order
* to release memory, and terminate the report writing.
* $return: 1 (TRUE) for success, 0 (FALSE) for failure
* $throws: UninitializedException
*/
int ExitSession();
/*
* Reset the internal command id counter to 1.
* $throws: UninitializedException
* $see: SetCmdCounter(int)
* $see: GetCmdCounter()
*/
void ResetCmdCounter();
/*
* Set the internal command id counter to the given value.
* $param val: the numeric value with which to set the command id counter.
* $throws: UninitializedException
* $see: ResetCmdCounter()
* $see: GetCmdCounter()
*/
void SetCmdCounter(int val);
/*
* Get the value of the internal command id counter.
* $return: the current value of the command id counter
* $throws: UninitializedException
* $see: SetCmdCounter(int)
* $see: ResetCmdCounter()
*/
int GetCmdCounter();
/*
* Retrieve the last error message generated by MFCSmith.
* This will be a description of a caught exception, or other error
* that occurred before or after sending information to TSAPI.
* This method may be called whether or not a session is active.
* $return: the last error message generated by MFCSmith
* $see: GetLastTSError()
*/
CString GetLastCError();
/*
* Retrieve the last error message generated by TSAPI.
* This will be a description of an error that occurred within
* the TSAPI code.
* $return: the last error message generated by TSAPI
* $throws: UninitializedException
* $see: GetLastCError()
*/
CString GetLastTSError();
/*
* Get the final Exit Code, once the playback is complete.
* $return: the exit code generated by the TestSmith Playback Engine.
* 0 (NO_ERR) represents success; any positive value
* represents a TestSmith error code. -1 indicates an error
* generated by MFCSmith.
*/
int GetExitCode();
/*
* Set up the TestSmith environment.
* This call can be made multiple times before a playback is commenced.
* It can also be called during a playback to change the existing
* environment.
* $param directive: a TestSmith directive to set the environment.
* $return: 1 (TRUE) for success, 0 (FALSE) for failure
* $throws: UninitializedException
* $href: set environment
*/
int SetEnv(CString directive);
/*
* Set the index for reading data from a csv file.
* $param index: the index to be set
* $return: 1 (TRUE) for success, 0 (FALSE) for failure
* $throws: UninitializedException
* $href: datadriven.html
*/
int SetDataIndex(int index);
/*
* Set a single TestSmith option.
* $param key: the name of the key to be set
* $param value: the value to set
* $return: 1 (TRUE) for success, 0 (FALSE) for failure, e.g. key not recognized
* $throws: UninitializedException
* $href: testsmith.settings
*/
int SetOption(CString key, CString value);
/*
* Get the value of one of the internal TestSmith int variables.
* The value must have been set by a previous TestSmith command.
* $param name: the name of a TestSmith integer variable
* $param value: (out) will contain the value of the variable
* $return: 1 (TRUE) for success, 0 (FALSE) for failure
* $throws: UninitializedException
* $href: variables.html
*/
int GetInt(CString name, int& value);
/*
* Get the value of one of the internal TestSmith string variables.
* The value must have been set by a previous TestSmith command.
* $param name: the name of a TestSmith string variable
* $param value: (out) will contain the value of the variable
* $return: 1 (TRUE) for success, 0 (FALSE) for failure
* $throws: UninitializedException
* $href: variables.html
*/
int GetString(CString name, CString& value);
//the named commands
//-------------------------------------------------------------------------
//window (Wnd)
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int WndInit(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int WndSetFocus(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int WndMove(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int WndClose(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int WndRelease(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int WndFindObj(CString params, int id = -1);
//mouse (Ms)
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int MsLClick(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int MsRClick(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int MsL2Click(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int MsR2Click(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int MsLDrag(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int MsRDrag(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int MsLDragDrop(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int MsRDragDrop(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int MsScroll(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int MsHover(CString params, int id = -1);
//menu (msMenu)
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int MsMenuSelect(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int MsMenuHilite(CString params, int id = -1);
//keyboard (Kb)
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int KbText(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int KbKey(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int KbMenuSelect(CString params, int id = -1);
//HTML (Html)
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int HtmlClick(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int HtmlInput(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int HtmlLink(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int HtmlSelect(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int HtmlChoice(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int HtmlCheck(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int HtmlText(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int HtmlNavigate(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int HtmlWriteMsg(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int HtmlSaveImg(CString params, int id = -1);
//internet (Inet)
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int InetRequest(LPTSTR params, int id = -1);
//validation (Val)
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int ValBitmap(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int ValSeekItem(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int ValHtmlElem(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int ValHtmlText(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int ValHtmlTitle(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int ValHtmlUrl(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int ValClipText(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int ValWindowText(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int ValEditText(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int ValListItem(CString params, int id = -1);
//ctrl commands (Ctrl)
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int CtrlEditSetText(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int CtrlListSetItem(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int CtrlButtonClick(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int CtrlButtonCheck(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int CtrlStaticClick(CString params, int id = -1);
//registry commands (Reg) - (not recordable)
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int RegRead(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int RegWrite(CString params, int id = -1);
//extra commands - (not recordable)
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int SetVar(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int ReportTime(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int System(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int PrintOk(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int PrintErr(CString params, int id = -1);
/*
* $param params: a CString containing all name=value parameter pairs.
* $param id: an explicit numeric identifier for the command.
* if not specified the internal command id counter will be used.
* $return: 0 (zero) for success, or a TestSmith error code.
* $throws: UninitializedException
* $href: click here
*/
int Noop(CString params, int id = -1);
|