简体   繁体   English

如何在硒运行测试时显示Snackbar?

[英]How to display Snackbar while selenium is running test?

I want to display snackbar while the selenium test is running. 我想在硒测试运行时显示小吃吧。 But as much as I know I need an html page so I can execute the javascript code for the snackbar and I running the test on a website that I cannot modify the code of it. 但据我所知,我需要一个html页面,所以我可以执行快餐栏的javascript代码,并在网站上运行测试,我无法修改它的代码。

I managed to display other type of messages but this is not what I need. 我设法显示其他类型的消息,但这不是我需要的。

If there is any other way to display a message on the screen while the test is running and the message is not interrupting the test - doesn't require to close the window and the message is disappearing after few seconds, I will be happy to hear. 如果在测试运行时有任何其他方式在屏幕上显示消息并且消息没有中断测试 - 不需要关闭窗口并且消息在几秒钟后消失,我将很高兴听到。

Snackbar example Snackbar示例

Thanks in advance 提前致谢

Simple answer is, no 简单的答案是,不

Selenium offers no way to display anything, period. Selenium无法显示任何内容,期间。 It's a way to hook into other systems and so you would have to rely on those systems to display your "snack bar". 这是一种挂钩其他系统的方法,所以你必须依靠这些系统来展示你的“小吃店”。

The only way to display something in a web browser would be to insert your own code to create the snack bar. 在Web浏览器中显示内容的唯一方法是插入自己的代码来创建小吃栏。 But that would invalidate the test as you're not testing the site; 但是,由于您没有测试该网站,这将使测试无效; you're testing the site and how it interacts with your code. 您正在测试该网站以及它与您的代码的交互方式。

You could try tapping the language you're using to write the testing scripts to display something. 您可以尝试使用您正在使用的语言编写测试脚本来显示某些内容。 For instance, it's very common when using Java to have System.out.println() to display information in the console. 例如,使用Java让System.out.println()在控制台中显示信息时非常常见。 You could create a whole application that runs beside Selenium that puts up an OS-specific message box. 您可以创建一个在Selenium旁边运行的整个应用程序,它会显示特定于操作系统的消息框。 But even then, there is a great chance of affecting the automation. 但即使这样,也很有可能影响自动化。

So there big question is, Why do you think you need to display something? 所以最大的问题是, 为什么你认为你需要展示一些东西?

Generally, the point of automation is to run through a series of steps unattended. 通常,自动化点是在无人值守的情况下执行一系列步骤。 Where no one would be watching the process as it goes through the motions. 在通过动议时,没有人会看到这个过程。 So who is the intended viewer of this snack bar? 那么这个小吃店的目标观众是谁?

The only explanation is for debugging reasons. 唯一的解释是出于调试原因。 In which case adding this extra code is the worst thing you can do . 在这种情况下,添加这些额外的代码是您可以做的最糟糕的事情 You are already having an issue and you are trying to compound it by adding extra code that could skew the results. 您已经遇到了问题,并且您正在尝试通过添加可能会使结果出现偏差的额外代码来复合它。 If you're trying to debug, then add external logging, such as the previously mentioned System.out.println() or an equivalent to your code and go from there. 如果您正在尝试调试,则添加外部日志记录,例如前面提到的System.out.println()或等效代码,然后从那里开始。 Something that would not effect the screen or the browser. 不会影响屏幕或浏览器的东西。

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

相关问题 运行时显示每个测试的状态 - Display the status of each test while running 如何使用thunk有条件地基于redux状态显示小吃店? - How to display a snackbar conditionally based on redux state using thunks? 当运行硒测试时,Firefox窗口不清晰时,Onblur事件触发会陷入混乱 - Onblur event firing gets messed up when firefox window is not in focus while running a selenium test 如何在 python 中运行 selenium 代码时激活加载器页面 - How to activate loader page while running selenium code in python 如何在运行自动化测试时全屏制作Safari浏览器 - how to make safari browser in full screen while running automation test 运行异步测试时出错 - Error while running async test 运行 Selenium Webdriver Test 时不会出现警报 - When running Selenium Webdriver Test no Alert appears Chrome扩展程序未在Selenium Javascript Webdriver测试中运行 - Chrome Extension Not Running in Selenium Javascript Webdriver Test 如何使用单个Snackbar并变成多个Snackbar - How To Use Single Snackbar And Turn Into Multi Snackbar 如何在我的应用栏上方(z-index)显示我的小吃店? - How can I display my snackbar display above(z-index) my app bar?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM