-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
👷 Deploy request for cypress-docs pending review.Visit the deploys page to approve it
|
✅ Deploy Preview for benevolent-cat-040f48 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
|
|
You will need to run linting, as prettier does not accept the semicolon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a couple of comments:
- The syntax doesn't seem right in the example
- The code could use some more context to explain why you might want to do this
Otherwise, this looks good! I would be happy to approve after these changes are made.
@@ -143,6 +143,12 @@ cy.get('form').within(() => { | |||
}) | |||
``` | |||
|
|||
#### Find an anchor element by its label/text, remove some attribute and click it | |||
|
There was a problem hiding this comment.
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:
The following may be useful to change remove a `target` of `"_blank"` before clicking a link that would otherwise launch a new tab/window: | |
#### Find an anchor element by its label/text, remove some attribute and click it | ||
|
||
```javascript | ||
cy.get('a', { name: 'My link text' }).invoke('removeAttr', 'target').click(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The syntax here is not correct - it looks like a mix of Cypress and Testing Library syntax, the following would work though:
cy.get('a', { name: 'My link text' }).invoke('removeAttr', 'target').click(); | |
cy.contains('a', 'hello').invoke('removeAttr', 'target').click(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the example is changed from cy.get()
to cy.contains()
, would it then need to be added to https://github.com/cypress-io/cypress-documentation/blob/main/docs/api/queries/contains.mdx instead?
@hlawuleka Thanks for the contribution! Could you please sign our CLA? Also can you address the feedback? Otherwise we'll need to close this PR. |
@hlawuleka We haven't heard anything from you, so we are closing this PR. If you have time to take another look, please re-open with the provided feedback addressed! |
No description provided.