首页 > 解决方案 > 无法从自动完成赛普拉斯中选择

问题描述

自动完成字段的自动选择

it('Test to grab the autocomplete values', ()=> {
    cy.visit('https://jqueryui.com/autocomplete/');
    cy.get('#tags').type('c')
        cy.get('#ui-id-2').first().click()
    })
})

它显示它被点击但它没有被选中

标签: javascriptautomated-testscypress

解决方案


你的代码基本没问题,但是需要在iframe

cy.visit('https://jqueryui.com/autocomplete/')
cy.get('iframe.demo-frame')
  .its('0.contentDocument.body')
  .within(() => {

    cy.get('#tags').type('c')
    cy.get('#ui-id-2').first().click()
    cy.get('#tags').should('have.value', 'ActionScript')
  })

推荐阅读