柏树E2E测试:如何在网页上的Toast容器(或)弹出窗口上测试短信?
html代码的屏幕截图,用于错误吐司弹出我正在尝试获得弹出元素(或)吐司包容器并断言文本,但是我得到了一个从未发现的错误。请有人帮忙吗?
describe('Wholesoft Login Page', function(){
it('Check Login popup', function(){
cy.visit('https://https://platform.wholesoftmarket.com/login')
cy.get('#email').type('[email protected]')
cy.get('#password').type('hello')
cy.get('button.btn.active').click()
cy.get('div').within(($div)=>{
cy.get('div.overlay-container').should('have.text','no record found')
})
})
})
screenshot of html code for the error toast popupI am trying to get the element of popup (or) toast-container and asserting the text, but I am getting an error that element never found. Please someone help?
describe('Wholesoft Login Page', function(){
it('Check Login popup', function(){
cy.visit('https://https://platform.wholesoftmarket.com/login')
cy.get('#email').type('[email protected]')
cy.get('#password').type('hello')
cy.get('button.btn.active').click()
cy.get('div').within(($div)=>{
cy.get('div.overlay-container').should('have.text','no record found')
})
})
})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要为元素设置更大的超时,等待在DOM中存在:
You need to set a bigger timeout for the element, waiting to be present in the DOM:
您需要等到可以看到烤面包或弹出元件才能访问它。
请确保元素选择器正确。
遵循CMD
You need to wait till the toast or pop-up element is visible to access it for further steps.
Please make sure element selector is right.
following cmd
只要您没有覆盖默认的CSS类,您可能只想选择以下内容以下内容的实体
,或者用ID替换#root,
而在您的React App渲染的位置),就超时而言,确保将其设置为等于或稍大,比toastcontainer组件的“自动差”属性。较高的设置只会不必要地降低测试流程。
编辑:.toastify__ toast-body div的内容如下:
。
[ 在这种特殊情况下,我解决了问题:
希望这可以帮助...
[1]: https://i.sstatic.net/l9o5j.png
Provided you did not override the default Toastify CSS classes, you may simply want to select the entity with something like:
(or replace #root by the id where your React app is rendered)
And as far as the timeout is of concern, just make sure that it is set equal or slightly greater than the 'autoClose' property of your ToastContainer component. Higher settings would just unnecessarily slower the tests flow.
Edit: the content of the .Toastify__toast-body div looks like this:
[.Toastify__toast-body snapshot][1]
so it has four children: the icon, the text, a close button and a progress bar. In this particular case, I solved the problem using:
Hope this can help...
[1]: https://i.sstatic.net/l9O5j.png