首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Cypress没有获取按钮类,并且无法选择或单击该按钮

Cypress没有获取按钮类,并且无法选择或单击该按钮
EN

Stack Overflow用户
提问于 2021-06-12 14:14:19
回答 1查看 67关注 0票数 0

我正在用cucumber开发cypress来测试我的应用。我创建了两个特征文件,并且一次只运行第二个特征。我需要点击按钮来搜索文件,当我尝试点击时,我可以看到cypress正在获取第一个特征文件按钮的值,而不是选择或单击第二个特征文件的按钮。

有没有人可以帮助解决这个问题?

EN

回答 1

Stack Overflow用户

发布于 2021-06-14 13:54:04

代码语言:javascript
运行
复制
    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() }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67946157

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档