Gathering detailed insights and metrics for cypress-xpath
Gathering detailed insights and metrics for cypress-xpath
Gathering detailed insights and metrics for cypress-xpath
Gathering detailed insights and metrics for cypress-xpath
@cypress/xpath
Adds XPath command to Cypress.io test runner
cypress-action
cypress.action is a project that aims to have a new framework to make cy.get easier, but this time you will be able to use it by attribute, tag, xpath, fullXpath and cssSelector
xpath_cypress
Use xpath selectors with cypress
cypress_xpath_lib
npm install cypress-xpath
Typescript
Module System
Node Version
NPM Version
JavaScript (93.61%)
HTML (6.39%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
147 Stars
190 Commits
31 Forks
30 Watchers
9 Branches
41 Contributors
Updated on May 23, 2024
Latest Version
2.0.1
Package Id
cypress-xpath@2.0.1
Unpacked Size
9.94 kB
Size
3.95 kB
File Count
5
NPM Version
7.21.0
Node Version
16.14.2
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
3
Adds XPath command to Cypress.io test runner
1npm install -D cypress-xpath
1yarn add cypress-xpath --dev
Then include in your project's support file
1require('cypress-xpath');
After installation your cy
object will have xpath
command.
1it('finds list items', () => { 2 cy.xpath('//ul[@class="todo-list"]//li').should('have.length', 3); 3});
You can also chain xpath
off of another command.
1it('finds list items', () => { 2 cy.xpath('//ul[@class="todo-list"]').xpath('./li').should('have.length', 3); 3});
As with other cy commands, it is scoped by cy.within()
.
1it('finds list items', () => { 2 cy.xpath('//ul[@class="todo-list"]').within(() => { 3 cy.xpath('./li').should('have.length', 3); 4 }); 5});
note: you can test XPath expressions from DevTools console using $x(...)
function, for example $x('//div')
to find all divs.
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:
1cy.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":
1cy.xpath('//body').xpath('.//script');
The same thing goes for within:
1cy.xpath('//body').within(() => { 2 cy.xpath('.//script'); 3});
This explanation was shamelessly copied from teamcapybara/capybara.
To properly load the types for cy.xpath
command, add to your spec file the following comment.
1/// <reference types="cypress-xpath" />
If using TypeScript, add cypress-xpath
to the list of types to be loaded in tsconfig.json
1{ 2 "compilerOptions": { 3 "types": ["cypress", "cypress-xpath"] 4 } 5}
For more, see Intelligent Code Completion
This project is licensed under the terms of the MIT license.
To update the Cypress version badge in this README file run
$ npm run badges
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 2/15 approved changesets -- score normalized to 1
Reason
project is archived
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
23 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More