Skip to main content

Posts

Showing posts with the label baseClass

Best place to add code for taking Screenshots with Selenium and Java

  If your UI automation code takes screenshot on failure in test method or page method, then it’s not good. We should handle that using a listener Or have a base class containing AfterMethod annotation that captures screenshots on failure. Use lateral approach (i.e. base class with afterMethod) if you aren’t using listeners in your framework. Go through this well explained article by Alex Siminiuc for more details: https://levelup.gitconnected.com/the-good-the-bad-and-the-ugly-of-taking-screenshots-with-selenium-and-java-c9da23e09842

The Base class in the Selenium framework

Authoring automated tests is quite easy but authoring easily human-readable and maintainable tests is much tougher. Especially, when your project grows in size and complexity. There are many approaches that can help you build your tests in a Selenium framework like correct handling of your Base Class well. The Base class should have these things: - the setup() and teardown() test methods. - the WebDriver object. - load your configuration/properties file here (can be a part of its constructor) - common aspects of all tests like handling sync issues, ScreenshotOnFailure, etc. - have a method to visit the site that returns the Index page object. - and All test classes should inherit it. P.S. My view on this topic is purely subjective. And in many cases, you may not be able to apply this type of approach to your framework.