【问题标题】:Some form inputs are being cleared when button is clicked单击按钮时正在清除某些表单输入
【发布时间】:2021-09-25 05:37:33
【问题描述】:

我正在使用 cypress 来自动化表单。我已经添加了所有输入,但是当我单击“预订”按钮或表单内的任何按钮时,某些输入字段会被清除。由于这个问题,我无法提交此表单。有什么解决办法吗?

cy.xpath("//div[contains(@class,'specific-translator')]/div[2]/input").first().type('hira@translator.dt',{force: true})
cy.xpath("//span[contains(text(),'Klicka')]").first().click()
cy.xpath("//div[contains(@class,'specific-translator')]/div[2]/input").first().should('have.value','hira@translator.dt')
cy.pause(10)
cy.xpath("//span[text()=' Boka ']").first().click()

[点击后译者字段被清除

【问题讨论】:

    标签: javascript testing automation cypress


    【解决方案1】:

    我不确定这是否适用于您:

        cy.xpath("//div[contains(@class,'specific-translator')]/div[2]/input").first().type('hira@translator.dt',{force: true}).as('inputVal')
        cy.xpath("//span[contains(text(),'Klicka')]").first().click()
        cy.get('@inputVal').invoke('val').then((text)=>
        {
            expect(text).to.equals('hira@translator.dt')
        })
        cy.pause(10)
        cy.xpath("//span[text()=' Boka ']").first().click()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-02-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-15
      • 2011-10-08
      • 2011-03-11
      • 1970-01-01
      相关资源
      最近更新 更多