This page is maintained for older versions of Rapise only. The latest documentation can be found at: https://rapisedoc.inflectra.com
Tester

Tester

Top  Previous  Next

 

Tester object. Use it to perform assertions during test playback and output relevant information to the report. You do not need to record or learn this object, it is always automatically available in any test.

 

 

Property Summary

 

Property

Description

Fail

Test status, test failed.

Info

Test status, test is neither passed nor failed.

Pass

Test status, test passed.

Unresolved

Test status, test status is unresolved, test terminated unexpectedly.

 

Action Summary

 

Action

Description

Assert

Checks if condition is 'true' and saves corresponding Report entry.

AssertEqual

Checks if obj1 equals to obj2 and saves corresponding Report entry.

AssertImage

Checks if 'img1' equals to image stored at 'path' and saves corresponding Report entry.

BeginTest

Marks beginning of a test with a given name.

CaptureDesktopImage

Captures image of the desktop and adds it to the report.

CaptureObjectImage

Captures image of an object and adds it to the report.

CaptureWindowImage

Captures image of an application window matched by title and class and adds it to the report.

EndTest

Marks end of a currently executed test.

FailTest

Stops test execution and sets it's status to failed.

GetReportAttribute

Gets report attribute previously set by PushReportAttribute or SetReportAttribute.

GetTestStatus

Gets status of currently executed test.

IgnoreStatus

In IgnoreStatus mode the assertion status is always treated as "Info".

Message

Saves corresponding Report message.

MessageBox

Shows message box to user.

MessageBoxPrompt

Shows message box with question to the user and checks if user presses "Yes" or "No".

PopReportAttribute

Resets an attribute to its previous value.

PushReportAttribute

Maintains "stacked" attributes.

ResetReportAttribute

Removes report attribute previously set by SetReportAttribute.

SetReportAttribute

Set persistent attribute.

SuppressReport

In SuppressReport mode all assertions are ignored.

 

Property Detail

 

Fail

Test status, test failed. Constant, equal to 0.

 

Type: number

 

Info

Test status, test is neither passed nor failed. Constant, equal to -2.

 

Type: number

 

Pass

Test status, test passed. Constant, equal to 1.

 

Type: number

 

Unresolved

Test status, test status is unresolved, test terminated unexpectedly. Constant, equal to -1.

 

Type: number

 

Action Detail

 

Assert(message, condition, data, tags)

Checks if condition is 'true' and saves corresponding Report entry. Assertion is an atomic piece of verification. Assertion may contain some additional data (links, images, comments) set via 'data' parameter.

 

Parameters:

 

Name

Type

Description

message

string

Message to put in the report.

condition

boolean

If 'true' - assertion is considered passed.

data

SeSReportLink |
SeSReportText |
SeSReportImage |
object[] |
string

Additional information to put in the report. If 'string' is passed, then data is considered as additional comment atribute. Or 'array' may be passed. Each entry in the array should be one of: SeSReportLink, SeSReportImage, SeSReportText.
Optional.

tags

object

Hash of attributes to set for this particular log entry.
Optional.

 

AssertEqual(message, obj1, obj2, data, tags)

Checks if obj1 equals to obj2 and saves corresponding Report entry. Assertion is an atomic piece of verification. Assertion may contain some additional data (links, images, comments) set via 'data' parameter.

 

Parameters:

 

Name

Type

Description

message

string

Message to put in the report.

obj1

object

First object to compare.

obj2

object

Second object to compare.

data

SeSReportLink |
SeSReportText |
SeSReportImage |
Object[]

Additional information to put in the report. If 'string' is passed, then data is considered as additional comment atribute. Or 'array' may be passed. Each entry in the array should be one of: SeSReportLink, SeSReportImage, SeSReportText.
Optional.

tags

object

Hash of attributes to set for this particular log entry.
Optional.

 

AssertImage(message, img1, path, data, tags)

Checks if 'img1' equals to image stored at 'path' and saves corresponding Report entry. Assertion is an atomic piece of verification. Assertion may contain some additional data (links, images, comments) set via 'data' parameter.

 

Parameters:

 

Name

Type

Description

message

string

Message to put in the report.

img1

object

ImageWrapper object (1st image to compare).

path

string

Path to the second image to compare.

data

SeSReportLink |
SeSReportText |
SeSReportImage |
Object[]

Additional information to put in the report. If 'string' is passed, then data is considered as additional comment atribute. Or 'array' may be passed. Each entry in the array should be one of: SeSReportLink, SeSReportImage, SeSReportText.
Optional.

tags

object

Hash of attributes to set for this particular log entry.
Optional.

 

BeginTest(name, path)

Marks beginning of a test with a given name.

 

Parameters:

 

Name

Type

Description

name

string

Test name

path

string

Path to the test, that is executed. This string will be shown as a comment.
Optional.

 

CaptureDesktopImage(caption)

Captures image of the desktop and adds it to the report.

 

Parameters:

 

Name

Type

Description

caption

string

Image title for the report.

 

CaptureObjectImage(caption, objId)

Captures image of an object and adds it to the report.

 

Parameters:

 

Name

Type

Description

caption

string

Image title for the report.

objId

string |
SeSObject

Id of an object or SeSObject instance.

 

CaptureWindowImage(caption, windowTitle, windowClass, bringToFront)

Captures image of an application window matched by title and class and adds it to the report.

 

Parameters:

 

Name

Type

Description

caption

string

Image title for the report.

windowTitle

string

String or regular expression to match window title.

windowClass

string

String or regular expression to match window class.
Optional, Default: regex:.*.

bringToFront

boolean

Set to 'false' to not restore the window before making the image.
Optional, Default: true.

 

EndTest()

Marks end of a currently executed test. Calculates test results and performs finalization of test execution.

 

FailTest(message)

Stops test execution and sets it's status to failed.

 

Parameters:

 

Name

Type

Description

message

string

Failure description.
Optional, Default: Test stopped on error.

 

GetReportAttribute(name)

Gets report attribute previously set by PushReportAttribute or SetReportAttribute.

 

Parameters:

 

Name

Type

Description

name

string

Attribute name.

 

GetTestStatus()

Gets status of currently executed test.

 

Returns:

 

One of: Tester.Info - test is neither passed nor failed; Tester.Pass - test passed; Tester.Fail - test failed; Tester.Unresolved - test status is unresolved, test terminated unexpectedly.

 

IgnoreStatus(ignore)

In IgnoreStatus mode the assertion status is always treated as "Info". Real status is written to "realStatus" attribute in this case and used just for information purposes (i.e. it does not affect final test status).

This function is used when the test case needs to set test status manually.

  Tester.IgnoreStatus(true);
  Tester.Assert("Ignored Assertion", false); // This assertion is failed. But its status is ignored.
  Tester.IgnoreStatus(false);
  Tester.Assert("Test passed", true);
  // The overall test is passed because failed assertion is ignored.

 

Parameters:

 

Name

Type

Description

ignore

boolean

Set to 'true' to report all messages but ignore the status (Pass/Fail)

 

Message(message, data, tags)

Saves corresponding Report message. Message may contain some additional data (links, images, comments) set via 'data' parameter.

 

Parameters:

 

Name

Type

Description

message

string

Message to put in the report

data

SeSReportLink |
SeSReportText |
SeSReportImage |
Object[]

Additional information to put in the report. If 'string' is passed, then data is considered as additional comment atribute. Or 'array' may be passed. Each entry in the array should be one of: SeSReportLink, SeSReportImage, SeSReportText.
Optional.

tags

object

Hash of attributes to set for this particular log entry.
Optional.

 

MessageBox(message)

Shows message box to user. Use it for verbose and manual testing.

 

Parameters:

 

Name

Type

Description

message

string

Message to display.

 

MessageBoxPrompt(question)

Shows message box with question to the user and checks if user presses "Yes" or "No". "Yes" => "Pass" goes to the report with this message. "No" => "Fail" is reported.

 

Parameters:

 

Name

Type

Description

question

string

Question to display.

 

PopReportAttribute(name)

Resets an attribute to its previous value. See PushReportAttribute for more information.

 

Parameters:

 

Name

Type

Description

name

string

Attribute name to recall from stack.

 

Returns:

 

string: Previous value. Null if no such stacked attribute found.

 

PushReportAttribute(name, value)

Maintains "stacked" attributes. Useful for nesting.


Example:


Main test sets scenario=Main. Then it calls another scenario (scenario Login) and then continues its own test actions.


We want all assertions to be attributed with current scenario name.

 function Main()
 {
     Tester.PushReportAttribute("scenario", "Main");
     Login();
     ...
     Tester.Assert("Main test passed", mainStatus); // Saved with scenario=Main
 }

 function Login()
 {
     Tester.PushReportAttribute("scenario", "Login");
     ... // Do login logic
     Tester.Assert("Login Result", loginStatus);
     Tester.PopReportAttribute("scenario"); // Set scenario value back to caller
 }

 

Parameters:

 

Name

Type

Description

name

string

Attribute name to recall from stack.

value

string

New attribute value.

 

ResetReportAttribute(name)

Removes report attribute previously set by SetReportAttribute.

 

Parameters:

 

Name

Type

Description

name

string

Attribute name.

 

SetReportAttribute(name, value)

Set persistent attribute. It will be set for all subsequent report items (assertions, tests, requirements, and so on). It may be changed by calling the ResetReportAttribute function.

 

Parameters:

 

Name

Type

Description

name

string

Attribute name to set.

value

string

New attribute value.

 

SuppressReport(suppress)

In SuppressReport mode all assertions are ignored. That means no lines are added to report and all statuses are treated as "Info". This mode is like IgnoreStatus mode but no status messages are added to report.

  Tester.SuppressReport(true);
  Tester.Assert("No assertion", false); // Status of this assertion will be ignored and no record will be added to report
  SeS('Obj1').DoClick(); // No line will be added to report and operation status will be ignored
  Tester.SuppressReport(false);

 

Parameters:

 

Name

Type

Description

suppress

boolean

Set to 'True' to suppress adding anything into the report.