Class: resetContext

hobs.actions.config. resetContext


new resetContext( [options])

Change test execution context (to another window or iframe)

Parameters:
Name Type Argument Description
options TestStepOptions <optional>

Test method extra options

Example
// Init test context to an iframe of the main window (#test-iframe)
 hobs.setContext($('#test-iframe').get(0));

 new hobs.TestCase("tc#1")

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

 // will change the context AND store the current context for possible reset
   .config.changeContext(function() {
     return hobs.find('#inner-iframe')
 })
 // => Now, context is #inner-iframe (inside #test-iframe)

 // From this point, test will execute in #inner-iframe context
 .click('.inner-button')

 // Reset to store context
 .config.resetContext()
 // => Now, context is #test-iframe

 // will fail as .inner-button does not exist in context
 .click('.inner-button');

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