Skip to content

Commit

Permalink
docs: change .toBeVisible() guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
angeloashmore committed Dec 21, 2023
1 parent ca61552 commit 0d23733
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions playwright/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,11 @@ this.customTypesLink = this.menu.getByText("Custom types", {
});
```

### Prefer using `.toBeVisible()` when testing the presense of visble elements
### Prefer using `.toBeVisible()` when testing the presence of elements

`.toBeVisible()` ensures the element is present and visible to users. Explicitly checking for visibility prevents a false-positive test where the element is in the DOM, but cannot be seen or interacted by the user.

> [!NOTE]
> This preference can be ignored if the targeted element is hidden.
If the element is purposely hidden, use `.toBeHidden()` or `.toBeAttached()`, depending on your use case.
If the element is purposely hidden, use `.not.toBeVisible()`.

### Don't use `.locator()`

Expand Down

0 comments on commit 0d23733

Please sign in to comment.