Released Selenide 6.13.0

Released Selenide 6.13.0

Banners support

Hi all!

Wow, today we released Selenide 6.13.0

Banners support

The problem

People often asked me: “What can I do if during a test execution, a banner can appear on the screen (or any other unexpected element)?”

Such a banner can cover other elements, can hide some important button - and your test might occasionally get broken.

I’ve always scolded these questions and insisted that you should control your testing environment. You should dictate when the banner should appear, and when it should not.

But this question was too popular. In the end, we decided to suggest a solution in Selenide.

Now you can all new method Selenide.onBanner() in the beginning of your test:

onBanner("#pizzaAds", CLOSE, ".btn-close");

How it works

By default, this method adds a listener to webdriver. Before every click or check, this listener will ask browser if there exists an element with given selector "#pizzaAds". If it exists, Selenide will try to close it by clicking button ".btn-close".

We called this method POLL. It’s very simple and stable, but it’s also relatively slow. Because Selenide needs to ask from browser many-many times if the banner has appeared. Every request takes some time.

Alternative methods

That’s why we added 2 alternative methods for checking if the banner exists. You can enable them by a global setting:

Configuration.bannerCloseMode = POLL; // the default mode

// Listens DOM change events via CDP:
Configuration.bannerCloseMode = CDP; // Works only in Chromium-based browsers

// Sends current page html to ChatGPT and asks if it contains a banner
Configuration.bannerCloseMode = CHATGPT; 

Or you can set mode as a parameter using using:


Custom logic

There is a more generic option if you need to implement some custom logic for handling banner. For example, you might need to find some info inside the banner before closing it:

  .withAction((banner, closeButton) -> {
     banner.find(".title").shouldHave(text("Your password has been changed."));
     String newPassword = banner.find(".new-password").text();

Feel free to try, experiment, register issues on GitHub. Feel free to suggest your algorithms for banner detection.

Let’s unite against banners!


Today we have few video about Selenide:

Andrei Solntsev