0
votes

I am working on cypress with cucumber to test my application. I have a created two feature files and running only second feature at a time. I need to click the button to search a file, and when tried to click, I can see the cypress is getting the value of first feature file button and not selecting or clicking the second feature file's button.

Can anyone help with issue?

1
Please add the code that you are trying, the step definition, and the feature files both.Alapan Das
@AlapanDas added the code, can you please check and help meKishore Selvam

1 Answers

0
votes
    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() }