我正在用cucumber开发cypress来测试我的应用。我创建了两个特征文件,并且一次只运行第二个特征。我需要点击按钮来搜索文件,当我尝试点击时,我可以看到cypress正在获取第一个特征文件按钮的值,而不是选择或单击第二个特征文件的按钮。
有没有人可以帮助解决这个问题?
发布于 2021-06-14 13:54:04
cypress\integration\test\FileNumber.feature
Scenario: Retrieve a list of file records
Given when user try to retrieve a list of file records
When user provides file number as "00TEST"
And clicks on search button
Then User able to see the file details
cypress\integration\test\ProductId.feature
Scenario: Retrieve a list of product records
Given when user try to retrieve a list of product records
When user provides product number as "01PROD"
And clicks on search button
Then User able to see the product details
cypress\support\step_definitons\Viewfiles.js
import { And, Given, Then, When } from "cypress-cucumber-preprocessor/steps";
import adminPage from '../pageobjects/adminPage';
Given("when user try to retrieve a list of file records", () => { adminPage.launchadmin(); });
When("user provides file number as {string}", (fileNumber) => { adminPage.fileNumberCheck(fileNumber); })
And("clicks on search button", () => { adminPage.searchButton(); }) Then("User able to see the file details", () => { adminPage.verifyTitleSucccessfullyLanded(); })
cypress\support\step_definitons\Viewproducts.js
import { And, Given, Then, When } from "cypress-cucumber-preprocessor/steps";
import adminPage from '../pageobjects/adminPage';
Given("when user try to retrieve a list of product records", () => { adminPage.launchadminNew(); });
When("user provides product number as {string}", (productNumber) => { adminPage.productNumberCheck(productNumber); })
And("clicks on search button", () => { adminPage.productSearchButton(); }) Then("User able to see the product details", () => { adminPage.verifyTitleSucccessfullyLanded(); })
cypress\support\pageobjects\adminPage
const FILE_NUMBER = '#fileNumber'
const PRODUCT_NUMBER = '#productNumber'
const PRODUCT_SEARCH_BTN='#productNumberSearch'
static launchadmin() { cy.url() .should('include', 'localhost:3000/') } static launchadminNew() { cy.visit( "localhost:3000/product" ); }
static fileNumberCheck(fileNumber) { cy.get(FILE_NUMBER).type(fileNumber) }
static productNumberCheck(productNumber) { cy.get(PRODUCT_NUMBER).type(productNumber) }
static searchButton() { cy.get(SEARCH_BTN).click() }
static productSearchButton() { cy.get(PRODUCT_SEARCH_BTN).click() }
https://stackoverflow.com/questions/67946157
复制相似问题