It finally happened! We released a major Selenide version 5.0.0
The biggest change in Selenide 5.0.0 is a global refactoring. This is internal change. It should not (almost) affect you. For those who are interested - I am going to share refactoring details in a separate post.
What changes are waiting you in Selenide 5.0.0?
You can open two browsers in test
First of all: don’t use this feature!
In most cases, it’s a bad idea to open two or three browsers in a test.
Typically people want it to test multi-user scenarios. Something like that:
- In one browser, open an admin panel and modify some setting
- In other browser, open a user page and verify that the setting has been applied correctly.
The right solution in this case is to test admin panel separately, and user page separately. Don’t mix different tests into one. When you need to setup environment for test (incl. changing any settings or emulating input from other user), you can use whatever tools (rest call, insert into database etc) but not through UI. You are testing UI - it means that you are not allowed to trust UI.
If you still want to use bad practice, the API looks like this:
SelenideDriver browser1 = new SelenideDriver();
SelenideDriver browser2 = new SelenideDriver();
browser1.open("https://google.com");
browser2.open("http://yandex.ru");
browser1.$(h1).shouldHave(text("Google"));
browser2.$(h1).shouldHave(text("Yandeks"));
See actual example in Selenide own tests
My thanks go to people who played an important role in this long-running refactoring:
- Iakiv Kramarenko for the initial idea,
- Alexei Barantsev for constructive and convincing arguments,
- Aliaksandr Rasolka for moral support and idea generation.
NB! Old good open
, $
, $$
still work, and I still recommend to use them.
They do use new SelenideDriver()
inside, but they correctly store and destroy it.
You just don’t need to reinvent the wheel and solve the same problems again and again.
Let me repeat myself: two browsers in one test is most probably a BAD PRACTICE!
Now Selenide uses Chrome by default
Many years ago, we chose Firefox as a default browser because it was the only browser which did not require installation of a webdriver binary. Nowadays this argument is not valid because 1) Firefox now also requires installation of geckodriver, and 2) Selenide can install webdrivers automatically.
From our experience, Chrome is faster and more stable. That’s why now is Chrome Era.
See issue 811 – thanks to Aliaksandr Rasolka for PR 812
Selenide does not maximize browser by default
At the beginning it seemed to be a good idea to open browser to the full screen size. It should make tests stable: more elements fit to the screen. Many people still think this way.
Actually it makes tests flaky because tests result depends on screen size which is a random uncontrollable variable. Our new recommendation to set browser size explicitly to the minimal size supported by your application.
Selenide 5.0.0 by default sets browsers size to 1366x768
because it is worlds’ most popular resolution by the moment. As usually, you can redefine it as any other setting.
See issue 810 – thanks to Aliaksandr Rasolka for PR 812
Selenide doesn’t open a browser automatically
Methods $
and $$
now throw an exception if browser is not opened yet (or is already closed).
The right way is to open a browser first (by calling open(url)
) and then search elements ($
, $$
etc).
Before this release, methods $
and $$
opened a new browser automatically if it was not open yet. This behaviour could be unexpected sometimes.
For example, people got Firefox when they expected Chrome. Or got two browsers when they expected one.
Yes, it was a bug in tests, but now Selenide helps to find it faster.
There are known cases when tests started failing after upgrade to Selenide 5.0.0 for two reasons:
- Page object fields were declared static, and browser was closed after every test. Static fields were initialized only once. Every following test didn’t re-initialize them, but got from a previous test
SelenideElement
instances containing a reference to (already closed) webdriver. Solution: make page object fields non-static. Static is evil.- Test class fields (in case of TestNG) were initialized in field declaration, not in
setUp
method. That’s why I love JUnit. Happy JUnit users can afford such a luxury:public class MyTest { SelenideElement header = $("h1"); }
But poor TestNG users are forced to move initialization to
@Before
-like methods:public class MyTest { SelenideElement header; @BeforeEach public void setUp() { header = $("h1"); } }
Looks ugly, right? My advice: forget TestNG. JUnit rules.
See issue 809
Cleaned up unused settings and features
See issue 806 – thanks to Aliaksandr Rasolka for PR 812
Among other changes, we removed the following settings:
browser
(useselenide.browser
instead)remote
(useselenide.remote
instead)selenide.browser-size
(useselenide.browserSize
instead)selenide.browser.version
(useselenide.browserVersion
instead)browser.version
(useselenide.browserVersion
instead)selenide.start-maximized
(useselenide.startMaximized
instead)selenide.chrome.switches
(useselenide.chromeSwitches
instead)chrome.switches
(useselenide.chromeSwitches
instead)selenide.page-load-strategy
(useselenide.pageLoadStrategy
instead)selenide.click-via-js
(useselenide.clickViaJs
instead)selenide.reports
(useselenide.reportsFolder
instead)
Removed junit5-api
api dependency
Selenide transitively pulled junit5-api
dependency to your project, even if you don’t use JUnit5. Apparently you don’t want it.
Now it doesn’t.
If you use JUnit5 and some classes disappeared from classpath after upgrade, you will need to add JUnit5 dependency explicitly:
"org.junit.jupiter:junit-jupiter-api:5.3.1"
.
And minor changes:
- Classes
AssertionMode
,SelectorMode
,FileDownloadMode
moved from classConfiguration
to packagecom.codeborne.selenide
. - Now Selenide throws
ElementIsNotClickableException
instead ofElementNotFoundException
(if element could not be clicked because it was covered by another element). - Selenide throws error if
Configuration.fileDownload == PROXY
butConfiguration.proxyEnabled == false
. You will need to explicitly setConfiguration.proxyEnabled=true
to download files via proxy. - 817 fix “FirefoxDriverFactory overwrites Firefox profile provided by Configuration” – thanks to Boris Osipov for PR 821
- bugfix: method Selenide.download() should not fail if there is no opened browser yet
- 825 Upgraded WebDriverManager to 3.0.0 (again)
- 825 Created a workaround for WebDriverManager, so that it doesn’t call github api too often (getting 403 error)
- 832 Added support for screenshots outside of “user.dir” in CI server – thanks Alex Yu
Technical changes (which probably will not affect you)
- Upgraded to htmlunitdriver 2.33.0
- Moved constants
IE
,FIREFOX
etc. from classWebDriverRunner
to its parent classBrowsers
- Moved classes
Selenide
,WebDriverRunner
,Configuration
to subfolder statics. - Moved default settings initialization from Configuration to SelenideConfig.
- when waiting for a condition, catch explicitly only needed exceptions instead of
Throwable
which is too generic. It does not make sense to wait for 4 seconds in case of IllegalStateException, FileNotFoundException etc.
News
- We moved Selenide project to a dedicated github organisation: github.com/selenide
- Just a reminder: selenide usage examples with different frameworks are located in a separate organisation github.com/selenide-examples
- We created a Selenide project template for Gradle
- A video from my DevCon 2018 speech was published: Selenide: fall in love after 15 slides
- Boring comparision: Selenide vs. Selenium: The War Of Technologies!!!
- 16.10.2018, Krakow, Agile & Automation Days - Selenide master class, Aleksei Vinogradov
- 7.11.2018, Belgrade, Test Conference - Rapid UI-Test automation with Selenide, Aleksei Vinogradov
- 18.10.2018, Moscow, anonymous automation engineers meetup - Configuration in tests. Gradle, Java, Selenide, Boris Osyanin
- Tomorrow there is a meetup in America - BDD with Selenide - 16.10.2018, Reston, VA
Selenide is an open-source library that can make a huge impact on and accelerate software delivery by introducing a concise API, shorter expressions, and many other capabilities.
We get 7 years old!
Time does go on. Could we imagine that? Selenide gets 7 at October, 25. Now it’s funny to look at the first commits:

How your upgrade went?
Share your experience, register github issues, discuss your problems in slack and gitter.
selenide.org
10.10.18