简体   繁体   中英

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.

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

Thanks in advance

Simple answer is, no

Selenium offers no way to display anything, period. 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. 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. You could create a whole application that runs beside Selenium that puts up an OS-specific message box. 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. Something that would not effect the screen or the browser.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM