UI.context

Limit the test to specific parts of a page.

Usage

UI.context(context, test)
Parameter Type Remarks
context string Element in the page to limit the test to. Specify a CSS selector or XPATH to target the element. If the CSS selector or XPATH matches multiple elements, the context will be set to all matches.
test function Test to run within the context

Example

Take this page for example, it has two identical forms to login and create account.

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")
})