Skip to content

Commit f7893e6

Browse files
committed
03/01: mention that you can chain locators
1 parent cf1dd6e commit f7893e6

File tree

1 file changed

+2
-0
lines changed
  • exercises/03.best-practices/01.solution.accessibility-selectors

1 file changed

+2
-0
lines changed

exercises/03.best-practices/01.solution.accessibility-selectors/README.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ Now to make sure that the input is visible for the user, I will write an asserti
5353
await expect.element(discountInput).toBeVisible()
5454
```
5555

56+
> 🦉 You can also _chain locators_ to access more specific elements. For example, `page.getByRole('navigation').getByRole('link', { name: 'My projects' })` is a great way to find a "My projects" link that is nested under the `role="navigation"`/`<nav>` parent, especially if there are multiple links with the same accessible name on the page.
57+
5658
So far so good!
5759

5860
Next on the list is the button that makes the whole form do something—the submit button. While I can select it by its text `'Apply discount'`, that would be quite a broad query. There can be _multiple elements_ with that same text on the page (e.g. a heading that also says "Apply discount"). A far more important desctiptor for this element is that _it is a button_.

0 commit comments

Comments
 (0)