Released Selenide 6.19.0

Released Selenide 6.19.0

Highlight the invisible
28.09.23

Good Sunday!
At the end of September, we released Selenide 6.19.0.


New method $.highlight() for highlighting a web element

I feel like we’re opening another Pandora’s box, but what can we do?

Well, we’ve added a method to highlight an element.

What is it needed for?

In normal situations, there is no need. :)

  • When your tests just run automatically on CI, there is no need to watch them. No need to highlight anything.
  • But when you need to make a cool demo at a conference, or just show running tests to colleagues - here highlighting may be useful. Or when you are debugging some tricky flaky test where it’s unclear what and when is being clicked.

How exactly is it highlighted?

At the moment, we suggest two highlighting options: with a background (default) or a border.

import static com.codeborne.selenide.HighlightOptions.*;

$("h1").highlight();              // by default - background()
$("h1").highlight(background());  // colored background
$("h1").highlight(border());      // colored border

You can use your own style for background and border:

$("h1").highlight(background("rgb(85, 180, 250);"));
$("h1").highlight(border("3px solid blue"));

Or even use totally custom CSS for highlighting:

$("h1").highlight(style("color: white; background-color: red;"));


Further development

For now, the method only highlights the element you specify. In the future, it might be worth adding automatic highlighting for each element that is interacted with. Such highlighting would allow you to make an effective demo or debug a tricky error.

Share your ideas, we’ll think about it.

See issue 1277, issue 2395 and PR 2481.


Strip invisible spaces in collections

As you remember, in Selenide 6.16.0 we speeded up working with collections with the help of JavaScript snippets. It turned out that in doing so we slightly changed the behavior for elements containing invisible spaces and other tricky characters.

Let’s say we have the following element on our page:

<div id="status">
  <span> Fighting spirit </span>
  <span>  seething&nbsp;\u200Breality  </span>
</div>

Then a collection check like this:

$$("#status span").shouldHave(texts("Fighting spirit", "seething reality"));

failed:

Expected :[Fighting spirit, seething reality]
Actual   :[Fighting spirit, seething reality]

Moreover, the message looks as if the texts are the same. But in the first line there is a regular space, and in the second there is an invisible space “​”.

Now Selenide will clean up the invisible spaces. Perhaps it’s arguable whether it’s right or wrong, but it meets WebDriver specification, and Selenium also works like this. And we will also comply.

See issue 2469 and PR 2482.
Thanks to Maksim Au6ojlut for the hint about spaces.


Upgrade to Selenium 4.13.0

Upgraded Selenium from 4.12.1 to 4.13.0
Here is Selenium changelog.

It contains several important bugfixes, and still runs on Java8. Catch it before he starts requiring Java 11+!

See PR 2479.


Removed strict check for “/wd/hub”

If you use Selenoid, you might notice that selenide-selenoid plugin checked that URL ends with a string /wd/hub. It turns out that URL may be different. So we removed this check.

See issue 2475.
Thanks Dmitry Plodukhin for PR 2476.


Replaced ElementsContainer by Container

In a recent release, we forbid page objects to inherit ElementsContainer.

This code doesn’t work anymore:

class LoginPage extends ElementsContainer {
}

I still insist that a page object doesn’t really need to extend ElementsContainer. But few users complained that they cannot rewrite their code because of legacy etc.
For such project, we created interface Container:

class LoginPage implements Container {
}

For the usual widgets, we also recommend changing extends ElementsContainer to implements Container.

The only difference is that it’s interface, not an abstract class (you need to write “implements” instead of “extends”), and it doesn’t have method getSelf(). And you shouldn’t really need it.

See issue 2439 and PR 2465.


Methods $.tap(), $.doubleTap() for mobile apps

import static com.codeborne.selenide.appium.SelenideAppium.$;

$(By.name("ComputeSumButton")).tap();
$(AppiumBy.xpath("//android.widget.Button")).doubleTap();
$(AppiumBy.xpath(".//*[@text='People Names']")).tap(longPressFor(ofSeconds(4)));

Thanks qwez for PR 2467.


Selector by class+index for mobile apps

import static com.codeborne.selenide.appium.AppiumSelectors.byClassNameAndIndex;
import static com.codeborne.selenide.appium.SelenideAppium.$;

$(byClassNameAndIndex("android.widget.TextView", 7)).tap();

Thanks to Amuthan Sakthivel for PR 2440.


News


Andrei Solntsev

selenide.org

28.09.23