SDET Unicorns

Page Object Model – Selenide Tutorial Series

Table of Content

In this tutorial, we will cover how to implement Page Object Model in Selenide. Page Object Model is a popular design pattern to improve code readability and maintainability as well as to reduce duplicacy in your code. Selenide makes it really to get Page objects setup, let’s take a look at how we can do that –

Setup Page Class

We first need to setup a page class where we can store all our page locators and page methods.

public class HomePage {
// add locators and methods here

Setup Page Locators

Once base page class is setup, we can start adding the Page locators to the class –

public class HomePage {

    public SelenideElement getStartedBtn() {
        return $("get-started"));

    public SelenideElement headingTitle() {
        return $("h1");

    public SelenideElement logoLink() {
        return $(By.xpath("//a[@class=\"custom-logo-link\"]"));

    public ElementsCollection linksList() {
        return $$("#primary-menu li[id*=menu-item]");

Note: Make sure to import all the necessary packages from Selenide if auto-import doesn’t work.

Setup Page Methods

Now that we have the page locators setup, we can start adding in necessary page methods to reduce code duplicacy –

    public HomePage open() {"");
        return this;

    public void assertUrl(String expectedUrl) {
        String url = WebDriverRunner.url();
        assertEquals(url, expectedUrl);

Update Tests to use POM

In your test file, you need to initialize the HomePage class and then start replacing your locators and adding in page locators as well as page methods. Here’s an example –

    public void testInteractingWithElements() {
        // Open page url

        // By ID

        // verify heading by CssSelector
            .shouldHave(text("Think different. Make different."));

        // verify by XPath

As seen above, in just few steps you can implement Page object model concepts in Selenide. To learn more, check out this video below –

Thanks for reading!

My Resources

Thrive Suite: The all-in-one WordPress theme I used to create my blog.
Jasper AI: My favorite AI writing tool.
Surfer SEO:  A tool to help you rank your content on the first page of Google.

Write Content Faster


Write blog posts that rank for affiliate terms!

Join our mailing list

Unlock the Secrets to Becoming a SDET Pro in the Industry!

Stay ahead of the curve! Join our mailing list for exclusive insights, tips, and the latest industry updates delivered straight to your inbox

Table of Content

Related Post

Differences Between CI/CD and DevOps

Key Differences Between CI/CD and DevOps

Software development is far from a simple journey that involves merely executing code and launching applications. It often presents challenges, as it’s rare to get everything right from the start. Each time you implement new or frequent code changes, you inadvertently introduce potential issues that can be time-consuming to resolve. This complexity necessitates a structured approach to ensure smooth production.

Read More »

Common Types of Software Bugs

Dealing with bugs is one of the biggest headaches in the software development lifecycle. No matter how carefully someone writes code, it’s impossible to create a software product that works perfectly every time. Skipping detailed testing often causes major issues later on.

Read More »