被赛普拉斯的另一种元素覆盖

时间:2020-09-29 07:59:07

标签: javascript node.js cypress

超时重试:cy.select()失败,因为此元素:

<select aria-describedby="searchDropdownDescription" class="nav-search-dropdown searchSelect" data-nav-digest="Xa0GQ+pPQ/tdsV+GmRWeXB8PUD0=" data-nav-selected="0" id="searchDropdownBox" name="url" style="display: block;" tabindex="0" title="Search in">...</select>

被另一个元素覆盖:

<input type="text" id="twotabsearchtextbox" value="" name="field-keywords" autocomplete="off" placeholder="" class="nav-input" dir="auto" tabindex="0" aria-label="Search">

解决此问题,或使用{force:true}禁用错误检查。 我的代码:

describe('Amazon test', function()
describe('Amazon test', function()
{
    it('Matching book', function()
    {
        cy.visit("https://amazon.com")
        cy.title().should('eq',"Amazon.com: Online Shopping for Electronics, Apparel, Computers, Books, DVDs & more")
        cy.get('#twotabsearchtextbox').click({force: true}).get('#searchDropdownBox').select('Books')
        
    })
  })

我该如何解决?

1 个答案:

答案 0 :(得分:1)

尝试一下:

cy.get('#twotabsearchtextbox').click().get('#searchDropdownBox').select('Books',{force: true})