在按钮上以cy.click() failed because it requires a DOM element. The subject received was: > undefined" after .click( )
的形式面对Cypry错误
it('with select tag test',function(){
cy.visit('https://www.htse.net/')
//pop up message window disappear
cy.wait(2000)
cy.get('.splashPopUp.show > .modal-dialog > .modal-content > .close > span',{timeout: 30000})
//cy.get(" div[class='splashPopUp modal fade show'] span[aria-hidden='true']")
//cy.get("div[class='splashPopUp modal fade show'] button[aria-label='Close']")
cy.wait(2000)
.click()
//.should('be.visible')
// cy.click({ force: true })
/*cy.on('window:alert',(str)=>{
expect(strt).to,equal('Aloha!')
})*/
cy.contains('ALOHA e Komo Mai')
cy.click({ force: true })
})
谢谢你的指导,我应用了你的建议,弹出窗口从主页上消失了,但面临下面提到的错误。请给我一些时间为它的解决方案也
CypressError
4100ms后重试超时:cy.click((失败,因为此元素不可见:
<button type="button" class="close" data-dismiss="modal" aria-label="Close">...</button>
该元素<button.close>不可见,因为它的父<div#exampleModal.ssplashPopUp.modal.fade>具有CSS属性:display:none
修复此问题,或使用{force:true}禁用错误检查。了解更多
7|cy.get('div.modal-dialog'(8|.fund("按钮关闭"(
9|.click({multiple:true}(|^
.click()
是一个子命令,您需要单击某个内容,因此它前面应该有一个返回元素的命令,如.get()
、.find()
等。
参考点击命令
错误用法
cy.click('.btn')
//错误,不能链接到'cy'cy.window().click()
//错误,'window'不产生DOM元素
看起来你想点击模式的右上角的"X">
cy.contains('div.modal-dialog', 'Where is all the inventory')
.find('button.close')
.click() // don't use multiple!
你甚至可以点击灰色背景
cy.get('div.splashPopUp')
.click()