assert

Provides generic assertion methods.

If you are using oxygen.conf.js, assert module must be added.

modules: ['web', 'log', 'assert']

contain

Asserts that the string value contains a substring.

Parameters:

Name

Type

Description

actual

String

Actual value.

contains

String

Verbatim string to be contained.

message

String

optional Message to throw if assertion fails

var user = web.getText('id=username') // returns admin
assert.contain(user, 'admin', 'error message')
assert.contain(
web.getText('id=username'),
'admin',
'error message'
)

equal

Asserts that two values are equal.

Parameters:

Name

Type

Description

actual

String

Actual value.

expected

String

Expected value. Either a verbatim string or a regex string prefixed with regex:.

message

String

optional Message to throw if assertion fails.

var usernameInput = web.isExists('//input[@id="username"]')
assert.equal(usernameInput, true, 'error message')
assert.equal(
web.isExists('//input[@id="username"]'),
true,
'error message'
)

fail

Fails test with the given message.

Parameters:

Name

Type

Description

message

String

optional Error message to return.

assert.fail('error message')
assert.fail(
'Error message: '
+ web.getText('//p[@id="error-message"]')
)

notEqual

Asserts that two values are not equal.

Parameters:

Name

Type

Description

actual

String

Actual value.

expected

String

Expected value. Either a verbatim string or a regex string prefixed with regex:.

message

String

optional Message to throw if assertion fails.

var loader = web.isVisible('//input[@id="loader "]')
assert.notEqual(loader, true, 'error message')
assert.notEqual(
web.isVisible('//input[@id="loader "]'),
true,
'error message'
)

pass

Passes the test with the given message.

Parameters:

Name

Type

Description

message

String

optional Message to return.

assert.pass('Passed')