Skip to main content

Locator Chaining

Since v1.1.0

Gwen has a locator chaining mechanism allowing you to locate elements within other elements or frames.

Locating elements in frames

For example, to locate a dropdown box inside a frame, you can chain two locators together like this:

  Given my frame can be located by id "frame_id"
And my dropdown box can be located by name "dropdown_name" in my frame

And then just use the dropdown box:

  When I select "Gwen" in my dropdown box

Locating elements in other elements

To locate an input element in a form, you can chain two locators together like this:

  Given my form can be located by name "form_name"
And my input field can be located by name "input_name" in my form

Then just use the input field:

  When I enter "Gwen" in my input field

Locating deeply nested elements

There is no limit to the number of locators you can chain. For example, you can define a locator for an input field in a form within a frame by chaining three locators together like this;

  Given my frame can be located by id "frame_id"
And my form can be located by name "form_name" in my frame
And my input field can be located by name "input_name" in my form