Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add example to expand the usage of the get method #5469

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/api/queries/get.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ cy.get('form').within(() => {
})
```

#### Find an anchor element by it's label/text, remove some attribute and click it
hlawuleka marked this conversation as resolved.
Show resolved Hide resolved

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to an add explanation of why this is useful. Something like:

Suggested change
The following may be useful to change remove a `target` of `"_blank"` before clicking a link that would otherwise launch a new tab/window:

```javascript
cy.get("a", { name: "My link text" }).invoke("removeAttr", "target").click();
hlawuleka marked this conversation as resolved.
Show resolved Hide resolved
```

### Get vs Find

The `cy.get` command always starts its search from the
Expand Down