如何在 TypeScript 项目中使用 Cypress 中的 xpath 定位器?
How to use xpath locator in Cypress with TypeScript project?
最初,xpath 插件在我的 cypress 项目中运行良好。安装 typescript 插件并从 javascript 移动到 Typescript。现在它开始在 xpath
上抛出错误
Property 'xpath' does not exist on type 'cy & EventEmitter'.ts(2339)
请建议,如何在 Cypress 项目中将 xpath 与 typescript 一起使用? cypress-xpath": "^1.6.2",
包含在 package.json
中
package.json 文件如下:
"devDependencies": {
"@types/node": "^14.17.8",
"add": "^2.0.6",
"cypress-cucumber-preprocessor": "^4.3.0",
"cypress-mochawesome-reporter": "^2.2.0",
"cypress-xpath": "^1.6.2",
"typescript": "^4.4.3",
"yarn": "^1.22.10"
},
"cypress-cucumber-preprocessor": {
"nonGlobalStepDefinitions": true
}
要使其正常工作,您必须将其添加到 tsconfig.json
文件中。
{
"compilerOptions": {
"types": ["cypress", "cypress-xpath"]
}
}
最初,xpath 插件在我的 cypress 项目中运行良好。安装 typescript 插件并从 javascript 移动到 Typescript。现在它开始在 xpath
上抛出错误Property 'xpath' does not exist on type 'cy & EventEmitter'.ts(2339)
请建议,如何在 Cypress 项目中将 xpath 与 typescript 一起使用? cypress-xpath": "^1.6.2",
包含在 package.json
package.json 文件如下:
"devDependencies": {
"@types/node": "^14.17.8",
"add": "^2.0.6",
"cypress-cucumber-preprocessor": "^4.3.0",
"cypress-mochawesome-reporter": "^2.2.0",
"cypress-xpath": "^1.6.2",
"typescript": "^4.4.3",
"yarn": "^1.22.10"
},
"cypress-cucumber-preprocessor": {
"nonGlobalStepDefinitions": true
}
要使其正常工作,您必须将其添加到 tsconfig.json
文件中。
{
"compilerOptions": {
"types": ["cypress", "cypress-xpath"]
}
}