Limiting test scope
These commands can be used to limit the scope of the test
List of commands
Command | Description |
---|---|
UI.context |
Limit the test to run on specific parts of a page |
UI.context
Limit the test to specific parts of a page.
Usage
UI.context(context, test)
Parameters
Parameter | Type | Remarks |
---|---|---|
context | string | Limit the test to specific parts of a page. Specify a CSS selector or XPATH to specify the element to limit the test to. If the CSS selector or XPATH matches multiple elements, the scope of the test will be set to all matches. |
test | function | Test to run using the context |
Example
Take this page for example, it has two identical forms to login and create account.
See the Pen gjoJoN by shiling (@shiling) on CodePen.
To limit the test to the login form, we can set the context using a CSS selector on the ID of the login form like this:
I.see("Please log in ") // this runs on the entire page
UI.context("#login-form", function(){ // the following commands runs on the login form on
I.fill("username", "hello@uilicious.com")
I.fill("password", "password")
I.click("login")
})