我正在使用通过NPM在Visual Studio代码上安装的柏树。我最近安装了一个依赖项,通过NPM在测试套件中使用X-Path,并在我的支持文件(e2e.js)中包含了必要的代码。当在我的文件中包括允许我使用“ cy.xpath”命令的引用时,我不确定是否正确构建了构建路径。柏树本身正在起作用,但是XPATH命令似乎是问题。

问题描述 投票:0回答:1

在我试图引用柏树 - Xpath的文件中,这就是我所拥有的:

/// <reference types="cypress" /> /// <reference types="cypress-xpath" /> describe("Test Contact Us form via Automation Test Store", () => { it("Should be able to submit a successful submission via contact us form", () => { cy.visit("https://www.automationteststore.com/"); //cy.get('.info_links_footer > :nth-child(5) > a').click(); cy.get('#ContactUsFrm_first_name').type("Joe"); cy.get('#ContactUsFrm_email').type("[email protected]"); cy.get('#ContactUsFrm_enquiry').type("Test"); cy.get('.col-md-6 > .btn').click(); }) })

VS代码识别cy.xpath,但是它不能解决上述依赖性问题。

BELOW是cypress.config.js文件:
const { defineConfig } = require("cypress");

module.exports = defineConfig({
  e2e: {
    setupNodeEvents(on, config) {
      // implement node event listeners here
    },
    specPattern: "cypress/e2e/**/*.{js,jsx,ts,tsx,feature}"
  },
});

我在这里尝试了一些答案,并尝试了各种终端命令,这些终端命令可能会解决问题,但没有任何效果。我不确定如何继续解决这个问题,任何帮助都将不胜感激。
	

类型参考线

/// <reference types="cypress-xpath" />

看起来像旧的(不推荐使用的)软件包。

集成软件包包括一个类型定义文件
index.d.ts
应该使用

访问该文件

/// <reference types="@cypress/xpath" />
javascript xpath automated-tests cypress cypress-xpath
1个回答
5
投票
具有键,并且在该文件夹中。

我的项目不使用Typescript,而是使用JavaScript的Cypress,但是Cypress-Xpath无法识别。那会做同样的工作吗?
toxpance.json具有键“类型”:“ src”,index.d.ts在该文件夹中。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.