Constructor
new Sequence()
- Source:
Examples
import { GOOGLE_FRAGMENT } from '../constants'
import { Sequence } from 'test-automation'
import GoogleFragment from '../fragments/GoogleFragment'
export default class GoogleSequence extends Sequence {
constructor() {
super()
this.setFragment(GOOGLE_FRAGMENT, new GoogleFragment())
this.setStep(() => this.getUrl('/'))
this.setStep(this.getFragment(GOOGLE_FRAGMENT).testElements)
}
}
import { FORM_SELECTOR, INPUT_SELECTOR, LINK_SELECTOR, GOOGLE_FRAGMENT, RESULT_FRAGMENT } from '../constants'
import { Sequence } from 'test-automation'
import GoogleFragment from '../fragments/GoogleFragment'
import PageFragment from '../fragments/PageFragment'
import ResultFragment from '../fragments/ResultFragment'
export default class GoogleSequence extends Sequence {
constructor () {
super()
const homepage = this.setFragment(GOOGLE_FRAGMENT, new PageFragment([new GoogleFragment()]))
const resultpage = this.setFragment(RESULT_FRAGMENT, new ResultFragment())
this.setStep([
() => this.getUrl('/'),
() => homepage.testElements(),
() => homepage.elementSendKeys(INPUT_SELECTOR, 'something'),
() => homepage.elementClear(INPUT_SELECTOR),
() => homepage.elementSendKeys(INPUT_SELECTOR, 'www.google.com'),
() => homepage.elementSubmit(FORM_SELECTOR),
() => resultpage.testElements(),
() => resultpage.elementClick(LINK_SELECTOR),
() => homepage.testElements()
])
}
}
Methods
getFragment(key) → {Fragment}
Gets the Fragment referenced by the key passed.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
key |
string
|
Symbol
|
The unique key associated with the Fragment. |
(async) getUrl(url) → {Promise}
[`async`] Getter method that gets the url specified to load in the browser.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
url |
string
|
The relative url path to load. |
Returns:
- Type:
-
Promise
The promise representing the browser get call.
(async) runSequence() → {Promise}
[`async`] Method that runs the sequence of test steps previously specified.
- Source:
Returns:
- Type:
-
Promise
The promise chain of test steps.
setFragment(key, fragment) → {Fragment}
Sets the Fragment to be referenced by the key passed.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
key |
string
|
Symbol
|
The unique key associated with the Fragment. |
fragment |
Fragment
|
The Fragment to associate with the key. |
setStep(step)
Sets a test step to be run, in order, during the test pass.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
step |
function
|
Array.<function()>
|
The function that wraps a test or action. |