Stay a while, oh moment!
The second release of Selenide 7.12.0 has been done in October. Don’t miss the update!
I can’t put into words the whole range of emotions…
When you spend every month hacking away at something, releasing it — and then suddenly see that people are actually reading the release notes and upgrading — isn’t that the best reward?
- Screenshots with DevTools/BiDi
- New locator
byLabel - New locators
byPlaceholder,byTitle,byAltText - New locator
byTestId - Mobile emulation
- Browser logs with DevTools/BiDi
- Search right in shadow host
byShadowCss - New method
$.unhighlight() - Update Selenium from 4.36.0 to 4.38.0
Screenshots with DevTools/BiDi
Selenide now uses a different method for taking screenshots than the standard webdriver method: either using DevTools (in Chromium) or BiDi (in Firefox).
While working on the video recorder, we noticed that this way is
- much faster, and
- doesn’t steal focus from the browser when running tests in parallel.
This mechanism has now been extended from the video recorder to all screenshots in Selenide.
See issue 2712 and PR 3153.
New locator byLabel
There’s a theory that it’s better to search web elements not by IDs or XPath, but rather like a real user - by text or label. Selenide has had text search since version 1.7 (2012), and now we’ve added the search by label:
$(byLabel("Song title")).val("Swan Lake");
With a second argument, you can optionally specify:
- either you need full text search or substring;
- either you need case-sensitive or case-insensitive search;
- either you need to ignore or preserve spaces.
$(byLabel("Song title"), fullText()).val("Swan Lake");
$(byLabel("Song"), partialText()).val("Silver Lining");
$(byLabel("Song title"), fullText().trimWhitespaces()).val("You are a Soldier");
$(byLabel("Songtitle"), fullText().ignoreWhitespaces()).val("It Happened in Russia");
$(byLabel("SONG TITLE"), fullText().caseInsensitive()).val("Daddy's Mistress");
See PR 3148.
New locators byPlaceholder, byTitle, byAltText
Added a few more locators to search elements by attributes placeholder, title and alt.
In fact, it was possible to use them before as well (since 2014, with version 1.10):
$(by("placeholder", "dovboyob"));
$(by("title", "jobu"));
$(by("alt", "Hloupá kurva"));
But now there are few dedicated methods - perhaps, this will serve as a hint to someone.
$(byPlaceholder("Specify the article"))
.val("Organization of a mass simultaneous gathering and/or movement of citizens in public places that resulted in a disturbance of public order.");
$(byTitle("Damn weekend potatoes"), partialText())
.hover();
$(byAltText("A picture to attract"), partialText().ignoreWhitespaces())
.shouldBe(image);
In all of these methods, you can specify as a second parameter
- full-text or partial text,
- case-sensitivity, and
- whitespace sensitivity.
See PR 3151.
New locator byTestId
A very popular pattern is to assign artificial IDs (data-test-id) to web elements,
so that they can be reliably searched for in tests.
<div data-test-id="top-quote">Chips are Satan's scales</div>
Again, it was already possible before: $("[data-test-id='top-quote']"),
but now there is a dedicated method:
$(byTestId("top-quote"))
.shouldHave(text("Chips are Satan's scales"));
The only catch is that this attribute might be named differently in different projects.
In Selenide, it’s named data-test-id by default - just because I like this name. :)
If you want to customize the attribute name, there are two options:
- Set
System.setProperty("selenide.test-id.attribute", "data-testid") - Add the following line to the
selenide.propertiesfile:selenide.test-id.attribute=data-testid
See PR 3151.
Switch Mobile emulation mode
Selenide has had the ability to enable mobile browser emulation mode for about six years now. But to enable it, you had to open a new browser.
Now you can toggle mobile mode on and off in an already open browser:
emulateDevice(Device.ONEPLUS_7T);
resetEmulation();
emulateDevice(Device.GALAXY_S21);
resetEmulation();
emulateDevice(new Device("Nokia 3210", 240, 320, 0.5));
resetEmulation();
(These are all my real phones. Guess which one is my favorite?)
See issue 2094 and PR 3159.
Collect browser logs with DevTools/BiDi
Selenide has a method for obtaining browser logs (including JavaScript errors from the page being tested):
List<String> webDriverLogs = getWebDriverLogs(BROWSER, Level.ALL);
assertThat(webDriverLogs).hasSize(6);
assertThat(webDriverLogs.get(0))
.contains("/bank/login 12:18 .*ReferenceError: \\$ is not defined");
The problem is that this method didn’t work in Firefox.
Because Firefox doesn’t support the standard webdriver method webdriver.manage().logs().
Now, this method will work in all normal browsers, since we now collect browser logs via the BiDi protocol. This protocol is also supposedly a w3c standard and is supported at least by Chromium and Firefox.
See issue 1636 and PR 3156.
Search right in shadow host byShadowCss
Now you can write a search like this:
$("#shadow-host")
.find(shadowCss("p")) // Previously, a second argument was required here
.shouldHave(text("Inside Shadow-DOM"));
Previously, this code didn’t compile because shadowCss("p") required a second argument.
See issue 3142. Thanks to Vivien Tintillier for PR 3143.
New method $.unhighlight()
Selenide has a method $.highlight(), which has been suffering
from loneliness for a long time. It missed a partner.
Now you can highlight and unhighlight any element:
$("#naoko").highlight();
$("#naoko").selectOption("13");
$("#naoko").unhighlight();
See issue 3057 and PR 3155.
Update Selenium from 4.36.0 to 4.38.0
And bumped the CDP version from v140 to v142.
This is the meaty release we’ve got.
Upgrade, rejoice, and stay optimistic. Silver Lining is just around the corner.
And let the swans dance!
selenide.org
29.10.25