Step · Target
Find page elements using plain text, XPath or selectors. This page covers target patterns, shortcuts, and examples for steps.
#id, Selector::, ClassName::, Name::, TagName::, shadow DOM) run on the practice form.Quickly copy an XPath with DevTools:
- Right‑click the target element (button, link, input) and choose Inspect.
- In the Elements panel, ensure the element is highlighted.
- Right‑click the highlighted node and choose Copy → Copy XPath.
- Paste the XPath into the step Target field.
The Target field is checked as you save. An empty Target, or a malformed expression when using XPath, an explicit selector or a regular expression, shows a warning under the field because the automation would stop at that step. New steps also support plain-text targets, as described below. Targets that are only known when the automation runs (Google Sheets values, placeholders such as <batchRepeat>) are not checked.
If a Target stops matching later because the page changed, you can pick the element again from the status bar instead of rewriting it here. See Fix Element Not Found.
Plain text
Added in v5.8.0In a new step you can name the element the way you would describe it, with no prefix and no XPath. Type what the field is called or what the button says.
| You type | What it matches |
|---|---|
email | Anything whose name, label or other attribute contains "email". If nothing matches, the text is tried as a CSS selector. |
"email" | Only what is exactly "email". |
/^e-?mail$/i | A regular expression. |
//input[@name="email"] | XPath, as always. |
The text is compared with these attributes of each field and button:
name,idautocomplete(exceptonandoff), for examplegiven-nameorpostal-code- the field's label
aria-label,placeholder,title- the visible text of buttons and links
value, for checkboxes, radio buttons and button inputs onlyclass,ng-model,data-bind,data-reactid,aria-describedby
Matching ignores upper and lower case. Use a regular expression when case matters.
<form>
<label for="fn">First name</label>
<input id="fn" name="first_name" autocomplete="given-name" /> 👈 First name, first_name, "given-name" <input name="email" placeholder="you@example.com" /> 👈 email <input name="confirm_email" /> 👈
confirm, "confirm_email" <button type="submit">Create account</button> 👈 Create account
</form>
With and without quotes
Without quotes, the text only has to be contained, and the closest matches win: elements that are exactly the text come first, then those that start with it, then those that contain it. In the form above, email fills the email field and leaves confirm_email alone.
With quotes, only an exact match counts. If the email field is ever removed from the page, email would move on to confirm_email, while "email" stops with "element not found". Use quotes when filling the wrong field would be worse than stopping.
When several elements match
The step runs against every match at the best matching level, the same as an XPath that matches several elements. "Like" clicks every button labelled "Like" and does not touch "Unlike".
If both visible and hidden elements match, only the visible ones are used. Pages often keep a hidden mobile copy of a desktop button.
To act on fewer elements, make the text more specific, add quotes, or use an XPath.
Plain text works in steps created in version 5.8.0 or later. A step created before that keeps reading its Target as an XPath, even after you edit it, so nothing you already have changes. To use plain text in an older automation, add a new step.
Prefixes such as #id, Selector:: and Name::, and XPath, work the same in old and new steps.
Two forms from other tools are also understood: text=View Form, which is the same as typing View Form, and button:has-text("Confirm"), which matches buttons containing that text. Other selectors from those tools are not supported.
XPath
XPath locates an element by its position and attributes in the DOM tree. See examples below.
Note
Chrome (Chromium) supports XPath 1.0. The examples below use XPath 1.0 syntax and show which elements are selected.
//div/a[1]
<div>
<a>One</a> 👈 selected
<a>Two</a>
</div>//div/a[last()]
<div>
<a>First</a>
<a>Middle</a>
<a>Last</a> 👈 selected
</div>//div/a[last()-1]
<div>
<a>First</a>
<a>Middle</a> 👈 selected
<a>Last</a>
</div>//div/a[position() > 2]
<div>
<a>First</a>
<a>Second</a>
<a>Third</a> 👈 selected <a>Fourth</a> 👈 selected
</div>//a[@href] (attribute present)
<div>
<a>First</a>
<a>Second</a>
<a href="#">Third</a> 👈 selected
<a>Fourth</a>
</div>//a[@href='google'] (attribute equals)
<div>
<a>First</a>
<a href="#">Second</a>
<a href="google">Third</a> 👈 selected
<a>Fourth</a>
</div>//button[@id='1'] (match by id)
<div>
<a>First</a>
<button type="button" id="1">Click me</button> 👈 selected
<a href="#">Second</a>
<a href="dhruv-techapps.github.io">Third</a>
<a>Fourth</a>
</div>//a[@data-rank < 3] (numeric comparison)
<div>
<a data-rank="1">Primary</a> 👈 selected <a data-rank="2">Secondary</a> 👈 selected
<a data-rank="3">Warning</a>
<a data-rank="4">Info</a>
</div>//button[contains(@class,'me')] (substring match)
<div>
<button type="button" id="1">Primary</button>
<button class="me second">Secondary</button> 👈 selected <button class="me warning">Warning</button> 👈 selected
<button class="me-too done">Me Too</button> 👈 selected (substring match)
</div>//button[contains(concat(' ', normalize-space(@class), ' '), ' me ')] (safe class match)
<div>
<button class="me second">Secondary</button> 👈 selected
<button class="me-too done">Me Too</button>
</div>//button[contains(text(),'Me')] (text contains)
<div>
<button type="button" id="1">Primary</button>
<button class="me second">Secondary</button>
<button class="me warning">Warning</button>
<button class="me-too done">Me Too</button> 👈 selected
</div>//button[starts-with(normalize-space(.), 'Sign')] (text starts-with)
<div>
<button>Sign in</button> 👈 selected <button>Signup</button> 👈 selected
<button>Log out</button>
</div>//span[contains(@class,'badge')][number(translate(normalize-space(.),' %','')) >= 50] (numeric text greater than or equal to 50)
<div>
<span class="badge">55 %</span> 👈 selected <span class="badge">50 %</span> 👈 selected
<span class="badge">45 %</span>
<span class="badge">43 %</span>
</div>//label[normalize-space(text())='Email']/following-sibling::input[1] (following sibling)
<div>
<label>Email</label>
<input type="email" /> 👈 selected
<input type="text" />
</div>//input[@id='street']/parent::* (parent)
<div>
<div class="field">
👈 selected
<input id="street" type="text" />
</div>
</div>//button[@type='submit']/ancestor::form (ancestor)
<form>
👈 selected
<button type="submit">Send</button>
</form>//li[@class='active']/preceding-sibling::li[1] (preceding sibling)
<ul>
<li>One</li>
👈 selected
<li class="active">Two</li>
<li>Three</li>
</ul>//div//button (descendant of div)
<div>
<section><button>Ok</button> 👈 selected</section>
</div>//button[@type='submit'][contains(@class,'primary')][not(@disabled)] (combined conditions)
<div>
<button type="submit" class="primary">Save</button> 👈 selected
<button type="submit" class="primary" disabled>Save</button>
<button class="primary">Not submit</button>
</div>Chat with us on
if you find it difficult to craft an XPath or have suggestions.
Get element by ID
When an element has an id attribute (for example, id="idValue"), you can target it with #idValue or Id::idValue.
Notes:
- IDs are intended to be unique. If duplicates exist, the first match is selected.
#inputEmail targets id="inputEmail". - #inputPassword targets id="inputPassword".<main class="form-signin">
<form>
<label for="inputEmail">Email address</label>
<input type="email" id="inputEmail" class="form-control" /> 👈 selected
<label for="inputPassword">Password</label>
<input type="password" id="inputPassword" class="form-control" /> 👈 selected
<button class="btn btn-primary" type="submit">Sign in</button>
</form>
</main>
Get elements by class name
When an element has a class list (for example, class="class-1 class-2"), target it with ClassName::class-1 class-2.
Notes:
- This selector can match multiple elements. The step runs against each match.
Referring to the HTML below:
ClassName::form-controltargetsclass="form-control"inputs.ClassName::btn btn-primarytargetsclass="btn btn-primary"buttons.
<main class="form-signin">
<form>
<label for="inputEmail">Email address</label>
<input type="email" id="inputEmail" class="form-control"> 👈 selected
<label for="inputPassword">Password</label>
<input type="password" id="inputPassword" class="form-control"> 👈 selected
<button class="btn btn-primary" type="submit">Sign in</button> 👈 selected
</form>
</main>
Get elements by name
When an element has a name attribute (for example, name="email"), target it with Name::email.
Notes:
- This selector can match multiple elements. The step runs against each match.
Referring to the HTML below:
Name::emailtargetsname="email".Name::passwordtargetsname="password".
<main class="form-signin">
<form>
<label for="inputEmail">Email address</label>
<input type="email" id="inputEmail" class="form-control" name="email"> 👈 selected
<label for="inputPassword">Password</label>
<input type="password" id="inputPassword" class="form-control" name="password"> 👈 selected
<button class="btn btn-primary" type="submit">Sign in</button>
</form>
</main>
Get elements by tag name
To target all elements of a given tag, use TagName::tagNameOfElement.
Notes:
- This selector matches all elements with the specified tag. The step runs against each match.
Referring to the HTML below:
TagName::maintargets<main>.TagName::formtargets<form>.TagName::inputtargets<input>.TagName::labeltargets<label>.TagName::buttontargets<button>.
<main class="form-signin">
<form>
<label for="inputEmail">Email address</label>
<input type="email" id="inputEmail" class="form-control" name="email">
<label for="inputPassword">Password</label>
<input type="password" id="inputPassword" class="form-control" name="password">
<button class="btn btn-primary" type="submit">Sign in</button>
</form>
</main>
Query Selector (single)
To target a specific element by CSS selector, use Selector::selector.
Notes:
- Selects the first matching element. If multiple elements match, only the first is used.
- If no match is found in the main document, open shadow roots are also searched.
Referring to the HTML below:
Selector::main.form-signintargets<main class="form-signin">.Selector::formtargets<form>.Selector::input[type="email"]targets<input type="email">.Selector::input[type="password"]targets<input type="password">.Selector::label[for]targets<label for="…">.Selector::button.btn.btn-primarytargets<button class="btn btn-primary">.
<main class="form-signin">
<form>
<label for="inputEmail">Email address</label>
<input type="email" id="inputEmail" class="form-control" name="email">
<label for="inputPassword">Password</label>
<input type="password" id="inputPassword" class="form-control" name="password">
<button class="btn btn-primary" type="submit">Sign in</button>
</form>
</main>
Query Selector All (multiple)
To target all matching elements by CSS selector, use SelectorAll::selector.
Find By Position
To target the top-most element at specific viewport coordinates, use Position::x,y.
Notes:
- Coordinates use viewport pixels (same behavior as
document.elementFromPoint(x, y)). - Coordinates are affected by page scroll and zoom.
- If no element is present at that point, retry behavior follows your step settings.
ClickAt::x,yandElementFromPoint::x,yare still supported for backward compatibility.
Examples:
Position::395,452Position::120.5,300
Dynamic XPath
- loop-repeat: iterate over rows using a placeholder in the XPath. For example, to click the button in each row: base XPath
//table/tr[1]/td[1]/button→//table/tr[<loopRepeat>]/td[1]/button. - step-repeat: iterate over columns or repeated targets within a row. Example:
//table/tr[1]/td[<stepRepeat>]/button. - session-count: refer to the current session number. Example:
//table/tr[1]/td[<sessionCount>]/button.