Class: ifElse

hobs.actions.core. ifElse


new ifElse(condition, execIfTrue, execIfFalse [, options])

Conditional execution

Parameters:
Name Type Argument Description
condition boolean | function

to evalute to true/false

execIfTrue hobs.TestSuite | hobs.TestCase

test element executed if condition has been evaluated to true

execIfFalse hobs.TestSuite | hobs.TestCase

test element executed if condition has been evaluated to false

options TestActionOptions <optional>

Test method extra options

Example
new hobs.TestCase("tc#1")

   // Navigate to shop home page
   .navigateTo("/shop/home.html")

   // If First load modal is present, remove it
   .ifElse(
     // condition function, return true if modal is present on shop home page
       function() { return hobs.find(".first-load-pop-up-modal").length > 0; },
     // if the modal is present, execute following test case to remove it
        new hobs.TestCase("Close first load modal")
               .click(".first-load-pop-up-modal .close-button")
   )

   // Continue test...

Extends

Methods


cancel()

Cancels step execution

Inherited From:

clone()

Returns a clone of the teststep

Inherited From:
Returns:
Type
hobs.TestStep

done(state, result)

Completes step execution

Parameters:
Name Type Description
state string

The final state of the step

result object

The result of the step execution

Inherited From:

duration( [format])

Get the duration of the test step execution

Parameters:
Name Type Argument Default Description
format string <optional>
'ms'

Specific format to convert the duration to. By default, milliseconds

Inherited From:
Returns:

The duration of execution in a specific format. Returns -1 if the test step has not been completely executed.

Type
number

exec( [options])

Executes the step. It consists of executing the function passed to the constructor.

Parameters:
Name Type Argument Description
options Object <optional>

Extra properties, extending the ones set at the instantiation of the step and passed, as first argument, to the step function.

Inherited From:
Returns:

A promise

Type
Object

execData(key, value)

Get/set execution metadata of the test step

Parameters:
Name Type Description
key string

The name of the option property

value *

The value to set the option property to

Inherited From:
Example
// Init TestStep
var step = new hobs.TestStep('ts1', 'Test Step #1');
// Execution metadata is set to an empty object by default

// Get all the options as an Object
step.execData(); // => {}

// Get the value of a specific option property
step.execData('prop1'); // => 'string'
step.execData('prop2'); // => 12

// Set the value of a specific option property
step.execData('prop1', true);
step.execData('prop2', 123);
step.execData(); // => {prop1: true, prop2: 123}

options(name, value)

Get/set options of the step

Parameters:
Name Type Description
name string

The name of the option property

value *

The value to set the option property to

Inherited From:
Example
// Init Step with options
var step = new hobs.Chaining.Step(null, {prop1: 'string', prop2: 12});

// Get all the options as an Object
step.options(); // => {prop1: 'string', prop2: 12}

// Get the value of a specific option property
step.options('prop1'); // => 'string'
step.options('prop2'); // => 12

// Set the value of a specific option property
step.options('prop1', true);
step.options('prop2', 123);
step.options(); // => {prop1: true, prop2: 123}

pause()

Pauses step execution

Inherited From:

result( [format] [, withDetails])

Returns a represention of the result of the test step execution.

Parameters:
Name Type Argument Default Description
format string <optional>

Use a specific hobs.reporters to render the result.

withDetails boolean <optional>
false

By default, hobs.reporters do not process children of successful test steps. Force this parameter to true to also get them.

Inherited From:
Returns:

An object representing the result of the execution.

Type
object

resume()

Resumes execution of a paused step

Inherited From:
Throws:

Will throw an error if the step is not paused


state()

Returns the current state of the step

Inherited From:
Returns:
Type
String