Have you heard of the Selenide test automation framework?
I didn't know much about it until I spoke with Hima Bindu Peteti about her and her team’s experience using it.
After hearing about all its features, I'm surprised more folks aren’t taking advantage of it for UI tests automation.
Here's why Selenide is Cool.
Selenium (and many other test automation frameworks) require a ton of custom code, and multiple libraries and utilities to get the functionality you need.
Hima explained that with Selenide, however, moving from a Quick Test Professional (QTP) to Selenium improved their automation efforts. Over time, though, they noticed there was a lot of boilerplate code required to create a simple Selenium test.
This is understandable since Selenium's not designed for test automation; Selenium is intended to drive a browser as if it was a real user.
Yes. You might be indirectly using it for test automation, but you end up writing a lot of code to get up and running.
For example, in Hima's organization, they have ten different projects going, and each project has multiple scrum teams.
This is problematic.
Write Less Automation Code
What happens if they have to code a method that creates a screenshot if a test fails?
One team might create that utility without knowing whether another team has already done the same thing.
If you scale this problem up, you'll find many folks in the same company end up writing duplicate utilities just for the sake of automation.
Duplicate code is what prompted Hima's team to create some new, reusable, company-wide utilities for everyone in the company.
It made perfect sense since it would help engineers to start focusing on the business logic instead of writing extra code.
But as her team began creating to set up utilities, they came across Selenide.
After looking into Selenide, they fell in love with it because it provided all the capabilities her team was about to try to create from scratch.
Out of the Box Ready to Go Framework
Why write code when you can pull in a library that takes care of all the functionality you need out of the box?
It saves a ton of time by helping to avoid unnecessary coding and maintenance.
After researching all the benefits of Selenide, Hima soon began rolling it out to their other teams.
This freed up more testers to concentrate solely on the business logic.
Because not a lot of code is needed using this library to create a test, they ended up writing more concise code.
They also noticed that their script reliability improved as well.
How is Selenide working in the real world?
Selenide in the Real World
Hima believes that with Agile, there shouldn't be a specific role for developers or testers.
Her company is moving towards cross-functional roles that everyone have to do everything.
So they all know what to do and what to implement, and they have to think about testing at the right level and at the right stage.
The problem, of course, is that like manual testers, developers sometimes have a hard time writing Selenium-based automation testing code.
So her team offers training to the folks who are willing to learn test automation, especially those who are coming from a manual testing background.
Many of them can quickly get up to speed and start to pick up small stories slowly.
It's been a multi-year journey for Hima's company, and most of her team members are doing great with their automation tasks.
For people who are willing to learn Selenide, it's easy to start creating automated tests.
How to get started with Automation and Selenide
You should first understand a little bit about coding practices like object-oriented principles.
Once you're comfortable with the object-oriented programming principles and some of the Java-related stuff, it's easy to begin using Selenide.
Selenide has a lot of documentation available on their website.
You can download Selenide and get started using their quick-start examples after following these simple steps:
• Create a Maven project
• Import the Selenide library
• Once the project is imported, say import Selenide.
• Automate the steps in your test
Selenide Configuration Perfect for CI Tool Like Jenkins
By default, if you are running Selenium tests and something goes wrong, you’ll need a way to see and debug whatever happened.
One technique would be to use a screenshot on the error(s) to show the state of the application during the failed test(s).
If you're starting a new project with Selenium, you have to build all these things into your framework, so you either need someone who has excellent design skills, or someone that has excellent coding skills to create custom methods for you.
But the Selenide library, by default, takes care of these things out of the box.
For instance, if you’re using Selenide and your test can't find an element, a screenshot will automatically capture the issue.
It will also save the image to your target folder. Logs will also show the expected and actual result(s).
The best part is that if anything changes, like the location of the screenshots for instance, it's effortless to change in this framework.
Selenide has something called Configuration.
public class Configuration
Configuration settings for Selenide
This class is designed so that every setting can be set via either system property or programmatically.
If you import the configuration class at the setup level, you will obtain access to easily set value for things like timeouts, etc.
This is great because you can then send all of those configuration parameters to Jenkins (or any other CI/CD system).
If, for example, your screenshot folder needs to be in a different location for different teams, you don't need to code this logic.
You can just pass the parameter to your CI system at runtime, and it will be automatically handled for you.
Some other examples of what you can control via the Configurations:
• Which browser to use
• Browser window size
• Browser version
• Proxy info
• Remote info
• Report info
• Page loads
What about support for Angular and React applications?
Sometimes folks think that only Protractor supports angular applications, but that's not true. Tools like Selenide also offer support for it.
If you're only using Selenium to test an Angular application there, you've probably noticed a synchronization problem when dealing with your system under test.
Because of this, many testers use Protractor, which is a JS binding that sits on top of Selenium and was explicitly designed for Angular applications.
This might be fine for brand new teams working on a new project, but most groups already have a reasonably robust Selenium Java framework. (FYI: Protractor doesn't seem to be getting updated, so not sure I would even recommend it for new projects.)
If you're already using Java, you're out of luck with using Protractor with your existing framework. In this case, you should check out Selenide.
Selenide supports Angular, React, and jQuery
How Selenide works is that it has additional, Angular-specific locators you can use. So instead of waiting only for ID, Xpath has a way to wait for the Angular element.
Also by default, every locator you write in Selenide automatically waits for four seconds with explicit conditions.
That means it waits until that particular element appears on the screen or in the DOM.
If you’re dealing with Selenium and want to achieve this same functionality, you have to import it explicitly, then write code for that expected condition.
By default, however, Selenide handles all the synchronizations.
And again—if you have to modify that synchronization for a different wait time depending on the environment, you can easily parameterize it and pass it a dynamic value at runtime.
You don't need to worry about changing things in code.
Selenide Test Automation Recommendations
Overall, Selenide looks like a very complete automation test tool framework. If you are using Java and need to create some automation, you definitely should give it a try.