javascript - 被另一个元素 Cypress 覆盖

标签 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()
{
    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')
        
    })
  })
我该如何解决?

最佳答案

尝试这个:

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

关于javascript - 被另一个元素 Cypress 覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64115257/

相关文章:

node.js - 如何将标记区域转换为 PostgreSQL 查询?

Cypress -等待由UI操作触发的xhr请求

javascript - 有IMG元素时如何设置插入符位置?

javascript - jQuery:click() 执行而不是绑定(bind)

javascript - 在浏览器中呈现后使用 javascript 和 css 样式化 XML(不是 HTML)

node.js - 向 sequelize 中的所有表添加一列

c# - 刷新下拉列表但保留旧的选定值 JSON

javascript - 第二次尝试时 react 函数松散状态

javascript - Cypress对象与JQuery对象,cy.wrap函数的作用

javascript - 为什么 Cypress 在运行 get 命令后说我的元素已分离?