-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
cypress-bot[bot]
committed
Jun 2, 2023
1 parent
ea4b6fc
commit c40f314
Showing
25 changed files
with
219 additions
and
905 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,3 @@ | ||
# @cypress/xpath | ||
|
||
> Adds XPath command to [Cypress.io](https://www.cypress.io) test runner | ||
## Install with npm | ||
|
||
```shell | ||
npm install -D @cypress/xpath | ||
``` | ||
|
||
## Install with Yarn | ||
|
||
```shell | ||
yarn add @cypress/xpath --dev | ||
``` | ||
|
||
Then include in your project's [support file](https://on.cypress.io/support-file) | ||
|
||
```js | ||
require('@cypress/xpath'); | ||
``` | ||
|
||
## Use | ||
|
||
After installation your `cy` object will have `xpath` command. | ||
|
||
```js | ||
it('finds list items', () => { | ||
cy.xpath('//ul[@class="todo-list"]//li').should('have.length', 3); | ||
}); | ||
``` | ||
|
||
You can also chain `xpath` off of another command. | ||
|
||
```js | ||
it('finds list items', () => { | ||
cy.xpath('//ul[@class="todo-list"]').xpath('./li').should('have.length', 3); | ||
}); | ||
``` | ||
|
||
As with other cy commands, it is scoped by `cy.within()`. | ||
|
||
```js | ||
it('finds list items', () => { | ||
cy.xpath('//ul[@class="todo-list"]').within(() => { | ||
cy.xpath('./li').should('have.length', 3); | ||
}); | ||
}); | ||
``` | ||
|
||
**note:** you can test XPath expressions from DevTools console using `$x(...)` function, for example `$x('//div')` to find all divs. | ||
|
||
See [cypress/e2e/spec.cy.js](cypress/e2e/spec.cy.js) | ||
|
||
## Beware the XPath // trap | ||
|
||
In XPath the expression // means something very specific, and it might not be what you think. Contrary to common belief, // means "anywhere in the document" not "anywhere in the current context". As an example: | ||
|
||
```js | ||
cy.xpath('//body').xpath('//script'); | ||
``` | ||
|
||
You might expect this to find all script tags in the body, but actually, it finds all script tags in the entire document, not only those in the body! What you're looking for is the .// expression which means "any descendant of the current node": | ||
|
||
```js | ||
cy.xpath('//body').xpath('.//script'); | ||
``` | ||
|
||
The same thing goes for within: | ||
|
||
```js | ||
cy.xpath('//body').within(() => { | ||
cy.xpath('.//script'); | ||
}); | ||
``` | ||
|
||
|
||
For more, see [Intelligent Code Completion](https://on.cypress.io/intellisense) | ||
|
||
## License | ||
|
||
This project is licensed under the terms of the [MIT license](/LICENSE.md). | ||
> @cypress/xpath has been deprecated and is no longer supported. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
c40f314
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.
Circle has built the
linux arm64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
c40f314
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.
Circle has built the
linux x64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally: