【问题标题】:How to use xpath locator in Cypress with TypeScript project?如何在 Cypress 中使用 xpath 定位器和 TypeScript 项目?
【发布时间】:2021-10-13 15:01:24
【问题描述】:

最初,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
  }

【问题讨论】:

    标签: typescript xpath cypress cypress-cucumber-preprocessor


    【解决方案1】:

    为此,您必须将其添加到您的 tsconfig.json 文件中。

    {
      "compilerOptions": {
        "types": ["cypress", "cypress-xpath"]
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-11
      • 2021-07-08
      • 1970-01-01
      • 2017-02-12
      • 2017-11-20
      • 2020-08-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多