Cypress 柏树e2e试验。无法获取素数toast元素以获取文本
我正在使用cypress进行e2e测试,我已经准备好了toast消息。我希望文本出现在toast中,但当我触发toast并尝试获取元素时,却无法获取元素Cypress 柏树e2e试验。无法获取素数toast元素以获取文本,cypress,Cypress,我正在使用cypress进行e2e测试,我已经准备好了toast消息。我希望文本出现在toast中,但当我触发toast并尝试获取元素时,却无法获取元素 启动toast链接:- 测试toast消息有点棘手,因为toast消息只会持续几秒钟。在这种情况下,您可能需要添加cy.wait()。我注意到的另一个问题是以下站点https://www.primefaces.org/primeng/#/toast在cypress chrome 70浏览器中加载时出现一些延迟。我添加了一些测试,用于测试toas
启动toast链接:- 测试toast消息有点棘手,因为
toast
消息只会持续几秒钟。在这种情况下,您可能需要添加cy.wait()
。我注意到的另一个问题是以下站点https://www.primefaces.org/primeng/#/toast
在cypress chrome 70浏览器中加载时出现一些延迟。我添加了一些测试,用于测试toast中的成功
和错误
消息文本。添加了通过测试的屏幕截图
describe('Find the toast message', function() {
it('Test the toast message', function() {
cy.visit('https://www.primefaces.org/primeng/#/toast')
cy.get('button[label="Success"]').find('span').contains("Success").click({force:true})
cy.wait(1000)
cy.get('div.ui-toast-detail').invoke('text')
.then((text)=>{
const toastText = text;
expect(toastText).to.equal("Order submitted");
})
cy.wait(1000)
cy.get('button[label="Error"]').find('span').contains("Error").click({force:true})
cy.wait(1000)
cy.get('.ui-toast-message-content').find('div').find('div').contains("Validation failed").invoke('text')
.then((text)=>{
const toastText = text;
expect(toastText).to.equal("Validation failed");
})
})
})
请提供更多信息。你能检查你的元素并告诉我们HTML是什么样子吗?还提供用于断言的cypress命令。我相信我或其他人能帮助你。