最初,xpath插件在我的cypress项目中工作得很好。安装了Typescript插件并从javascript移到了typescript。现在,它开始在xpath上抛出一个错误
Property 'xpath' does not exist on type 'cy & EventEmitter'.ts(2339)

请建议,如何在Cypress项目中使用xpath和typescript ? package.json中包含cypress-xpath": "^1.6.2",
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
}发布于 2021-10-13 15:07:33
为了让它起作用,你必须在你的tsconfig.json文件中添加这个。
{
"compilerOptions": {
"types": ["cypress", "cypress-xpath"]
}
}https://stackoverflow.com/questions/69557862
复制相似问题