简体   繁体   English

当Toastr通知出现时应触发事件

[英]Event should trigger when Toastr notification appears

i want to trigger an event using protractor for close the Toastr notification messages. 我想使用量角器触发事件​​以关闭Toastr通知消息。 whenever the notification appears this event should triggered.. is this possible?? 每当通知出现时,都应触发此事件。这可能吗?

I have 10 forms ,i am validating these forms using protractor. 我有10个表格,我正在使用量角器验证这些表格。 In each form i have editable text fields. 在每种形式中,我都有可编辑的文本字段。 If you add/edit/delete any fields you will get toastr notification message. 如果您添加/编辑/删除任何字段,您将收到烤面包机通知消息。 I want to close these messge whenever it appears in my appliaction. 每当应用程序中出现这些消息时,我都想将其关闭。 is this possible?? 这可能吗?? Thanks in advance.. 提前致谢..

You can execute JS code while running your test for closing toastr notification, you could try this one (I tested it in their demo project - run this code toastr.remove() in a console when toastr notification was shown): 您可以在运行测试以关闭toastr通知的同时执行JS代码,也可以尝试执行此代码(我在他们的演示项目中对其进行了测试-当显示toastr通知时,在控制台中运行此代码toastr.remove() ):

await browser.executeScript(toastr.remove())

note that browser.executeScript() return Promise so you need to resolve it. 请注意, browser.executeScript()返回Promise因此您需要解决它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 单击输入以触发焦点事件 - Click an input to trigger focus event 如何在e2e测试中触发'swipeleft'事件(量角器) - How to trigger 'swipeleft' event in e2e test (protractor) 如何在 Angular 2 中使用量角器测试 ngx-toastr - How to test ngx-toastr with protractor in Angular 2 什么时候应该使用getInnerHtml()方法? - When getInnerHtml() method should be used? 量角器,我应该在点击后使用then() - Protractor, when should I use then() after a click() 使用IJavaScriptExecutor时如何挂钩自定义JavaScript触发器 - How to hook to custom javascript trigger when using IJavaScriptExecutor 我们什么时候应该将 .then 与 Protractor Promise 一起使用? - When should we use .then with Protractor Promise? Angular2单元测试环境设置? 如何触发鼠标事件? - Angular2 unit test environment setup? How to do trigger mouse event? 当我尝试使用 cucumber 运行 protractor 测试时,出现以下错误消息“E/launcher - Process exited with error code 1” - When I try to run protractor test with cucumber the following error message appears “E/launcher - Process exited with error code 1” 什么时候应该使用 element.all(locator).then(thenFunction) 或 element.all(locator)? - When should element.all(locator).then(thenFunction) or element.all(locator) be used?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM