|
TSCAPI Class and Method Definitions
//Exception classes
//==============================================================================
/*
* UninitializedException
* Thrown when a call is made to any (other) method prior to calling InitSession
*/
class UninitializedException
{
public:
LPTSTR reason;
UninitializedException(LPTSTR why) : reason(why) {}
};
/*
* InSessionException
* Thrown when a second call is made to InitSession, before ExitSession is called
*/
class InSessionException
{
public:
LPTSTR reason;
InSessionException(LPTSTR why) : reason(why) {}
};
//==============================================================================
/*
* The CSmith 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 CSmith
{
public:
/* constructor */
CSmith();
/* destructor */
virtual ~CSmith();
/*
* Main entry point to run a CSmith Session.
* This method must be overidden by any class that extends CSmith.
* $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(LPTSTR data = EMPTY) = 0;
/* Representation of an empty String */
static const LPTSTR EMPTY;
/* Representation of a single space character */
static const LPTSTR 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 CSmith 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(LPTSTR 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 CSmith.
* 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 CSmith
* $see: GetLastTSError()
*/
LPTSTR 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()
*/
LPTSTR 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 CSmith.
*/
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(LPTSTR 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(LPTSTR key, LPTSTR 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(LPTSTR 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(LPTSTR name, LPTSTR& value);
//the named commands
//-------------------------------------------------------------------------
//window (Wnd)
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
//mouse (Ms)
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
//menu (msMenu)
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
//keyboard (Kb)
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
//HTML (Html)
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
//internet (Inet)
/*
* $param params: a LPTSTR 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 LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
//ctrl commands (Ctrl)
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
//registry commands (Reg) - (not recordable)
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
//extra commands - (not recordable)
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
/*
* $param params: a LPTSTR 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(LPTSTR params, int id = -1);
|