Skip to content

Locator Chaining

Branko Juric edited this page Feb 11, 2016 · 4 revisions

Gwen logo

Gwen-web version 1.1.0 introduces a locator chaining mechanism allowing you to easily locate elements within other elements or frames. The DSL to support this is:

<element> can be located by <locator> "<expression>" in <container>

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

Also, executing dry runs will detect any broken links in chains.

Clone this wiki locally