0

我正在用黄瓜研究柏树来测试我的应用程序。我创建了两个功能文件,一次只运行第二个功能。我需要单击按钮来搜索文件,当尝试单击时,我可以看到柏树正在获取第一个功能文件按钮的值,而不是选择或单击第二个功能文件的按钮。

任何人都可以帮助解决问题吗?

4

1 回答 1

0
    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() }
于 2021-06-14T05:54:04.350 回答