-
Notifications
You must be signed in to change notification settings - Fork 0
Step implementation
When you open launcher URL in browser it creates window with test dispatcher ecballium. Content of this window is permanent while test is running.
After this ecballium loads the following:
- Standard step library (lib.js)
- Feature file with scenarios (simple.feature, name of file is from URL hash)
- Library (simple.js)
ecballium compiles feature file and start to execute step from scenario. Before steps execution and after URL navigation ecballium injects script to target (ecballiumbot.js) and it creates singleton objects ecballiumbot on target. This bot waits on target side command from ecballium. Then step is completed on target side it notify ecballium. If test navigates from the current page ecballiumbot handle this and notify ecballium too.
Also ecballiumbot contains a set of test helpers.
To define your own step you should define your library file (simple.js for example):
ecballiumbot.register_handlers [ [/^Do something (.+) with (.*)/, /^Execute (.+) on (.*)/, /^Make something (.+)/, (par1,par2)-> if some_condition(par1,par2) @done('success') else @done('failed') ] ]
Method ecballiumbot.register_handlers is used to add new handler to common container.
Argument is the list of step handlers.
Step handler contains several JS regular expressions which used for description of step pattern and function as last element in the list. So you can define one function on several different step. It is useful if there are several variant of step description.
Function in handler gets as this instance of ecballiumbot.
Method this.done is used to notify ecballium that test step is completed and returns status of execution.
There are several way to send data from step
-
From step sentence
This data will be sent as function argument -
Multiline string
You can access it using @multiline property. -
Tables data
You can access it using @hashes.
Aliases is intended to create parameters translation phrases from feature file to some technical mean (selectors, URLs, regexps, equivalent phrases, language translation and many others)
To create aliases use the following:
ecballiumbot.register_handlers 'big button':'button.big' # selector 'main page':'../index.html' # URL 'is not':'are not' # equivalent phrases 'ya': 'yes' # language translation 'only nums':/[0-9]+/ # regexp
-
ecb
The reference to ecballium instance. It is used to save variable between test steps. -
A(alias)
This method is used to resolve alias to actual value. If argument is quoted this function just make unquote of argument without resolving of alias. -
assert(condition,msg)
This method notifies ecballium about condition failing and break step execution. -
fail(condition,msg)
This method has the same behavior as previous but also breaks scenario execution. -
on_redirect
handler to handle page leaving. You can save values to ecballium before bot dies. -
done(status)
signalizes to dispatcher what step is done and returns status. Status can be success or failed.