Locator Strategy
Info
INGenious uses the built-in locator strategy exposed by Playwright and provides an easy interface to configure them
Role
Locate by Role
Consider this DOM example :
You can locate each element by its implicit role:
Exact
Option
Sometimes you may have texts or names with partial matches in the DOM. For example :
- A
Button
with textSubmit
- A
Button
with textSubmit Your Application
In this case, to identify the first one, you can use the following:
In INGenious Playwright Studio, you will add it as this :Label
Locate by Label
Consider this DOM example :
You can locate the element by the label text:
- Password Input Box
Exact
Option
Sometimes you may have texts or Labels with partial matches in the DOM. For example :
- A
Label
with textAddress
- A
Label
with textSecondary Address
In this case, to identify the first one, you can use the following:
In INGenious Playwright Studio, you will add it as this :Placeholder
Locate by Placeholder
Consider this DOM example :
You can locate the element by the placeholder text:
- Input Box
Exact
Option
Sometimes you may have placeholder with partial matches in the DOM. For example :
- A
Placeholder
with textEmail
- A
Placeholder
with textSecondary Email
In this case, to identify the first one, you can use the following:
In INGenious Playwright Studio, you will add it as this :Text
Locate by Text
Consider this DOM example :
You can locate the element by the text it contains:
- Span
Exact
Option
Sometimes you may have texts with partial matches in the DOM. For example :
- A
header
with textWelcome
- A
span
with textWelcome, John
In this case, to identify the first one, you can use the following:
In INGenious Playwright Studio, you will add it as this :Alt Text
Locate by Alt Text
Consider this DOM example :
You can locate the element by the alt text:
- Image
Exact
Option
Sometimes you may have alt texts with partial matches in the DOM. For example :
- An
img
with alt testING
- An
img
with alt textING Lion
In this case, to identify the first one, you can use the following:
In INGenious Playwright Studio, you will add it as this :Title
Locate by Title
Consider this DOM example :
You can locate the element by the title :
- Image
Exact
Option
Sometimes you may have titles with partial matches in the DOM. For example :
- A
span
with titlePayments
- An
span
with titleDomestic Payments
In this case, to identify the first one, you can use the following:
In INGenious Playwright Studio, you will add it as this :Test Id
Locate by Test Id
Consider this DOM example :
You can locate the element by the title :
- Button
XPath or CSS
Locate by XPath or CSS
- For CSS :
In INGenious Playwright Studio, you will add it as this :
- For Xpath :
In INGenious Playwright Studio, you will add it as this :
Piercing Shadow DOM
Locate in Shadow DOM
All locators in Playwright by default work with elements in Shadow DOM. The exceptions are:
- Locating by XPath does not pierce shadow roots.
- Closed-mode shadow roots are not supported.
Consider the following example with a custom web component:
<x-details role=button aria-expanded=true aria-controls=inner-details>
<div>Title</div>
#shadow-root
<div id=inner-details>Details</div>
</x-details>
In INGenious Playwright Studio, you will add it as this :
Frames
Locate in Frames
All locators in Playwright by default work with elements inside a frame/iframe. But first you need to let the page locate the frame
using the framelocator
function.
You can do that in this way :
In INGenious Playwright Studio, you will add it as this :
If there are nested frames, then just add the frame locators separated by semicolon, in the Frame box :