How to use X-path in Cypress.
As a automation engineer everyone us is familiar with locators that is being used widely. Cypress.io supports only CSS selectors (jQuery Selectors), but what happens if you are not familiar with CSS selector. so let’s take a look on how to use X-path in Cypress.
Prerequisite:
Before we start you should aware about basic syntax of cypress along with how to find X-path locators, here I assume you are aware about those things, so let start !!
Installation:
Install with npm
install -D cypress-xpath
Install with Yarn
yarn add cypress-xpath — dev
Then include in your project’s cypress/support/index.js
require(‘cypress-xpath’)
without using above line in index.js
after including require(‘cypress-xpath’) in cypress/support/index.js
TypeScript and IntelliSense support
To properly load the types for cy.xpath
command, add to your spec file the following comment.
/// <reference types=”cypress-xpath” />
Cheers!!!
Note: If you have any query please feel free to post here, Thanks!