FluentLenium 1.0 and 3.0 brings many new features but also comes with breaking changes.
If you have some tests written using previous version, reading this guideline should help you to migrate.
Some changes are required in maven configuration.
- Add dependency to Selenium drivers actually used.
In previous version, overriding
getDefaultDriver() method was the only way to define
WebDriver to use. FluentLenium now provides configuration features including
capabilities properties that should be enough for most use case.
If you still need to instantiate the WebDriver manually, or if configuration
features doesn’t seem to integrates well in your environment,
getDefaultDriver() has been renamed to
and can still be overridden.
Keep in mind that events related features requires to wrap the
WebDriver instance into
TriggerModeenumeration values (ie:
Search method names
Some methods have been renamed and others have been removed to improve consistency and reduce codebase.
find(..., index)occurrences with
Element method names
Many method prefixes like
gethave been removed from method names. Methods like
getAttribute(name)have been renamed with their shorter form
text(...)setter has been renamed in
write(...)to avoid collision with
fill().withValues()has been renamed to
fill().withText()to avoid confusion with
value()that retrieves the
Conditions and await()
await() now supports more conditions, provides better error message, and is easier to maintain.
await().untilEach() match the condition when each element match the condition
await().until() match the condition when at least one element match the condition.
isNotPresent() has been removed, in favor of
not() method on condition builder
allows to negate any condition.
You can also check the exact same conditions on elements or list of elements, using
Pages and Components
- Each method available in
FluentTestis now available in both
FluentWebElement, allowing implementation of any logic into Pages and Components.
- Ensure your Page Objects extends
FluentPageand have a public empty constructor.
- Ensure your Components extends
FluentWebElementand have a constructor matching
createPagemethod has been removed in favor of
A Component is roughly the same thing as a Page Object. A Page Object is global, but a Component is local and attached
to an element so it can appear many time in a single page. A component can be created with
FluentLenium now supports Ajax natively, using either injected elements or
find search methods.
@WaitHook makes writing Ajax Webapp tests as simple as writing Static Website tests.
@AjaxElementhas been removed.
When using search methods
el, effective search is NOT performed at invocation time.
It’s a major change in FluentLenium 1.0. Those methods now returns a Lazy Locator implementing
Those locators looks like elements from previous versions, but the search will be performed lazily, when invoking the first action or check on the element.
So beware if you used to rely on catching
NoSuchElementException: Those exceptions will now be
raised later in the test, or even not raised at all the element is not actively used.
You may use
FluentList#now() to force the search at any time.
When using raw Selenium, explicit waits may spoil testing code and using implicit wait can be a solution. But using implicit waits may hard to diagnose delays when running tests.
FluentLenium now advocates for never using implicit wait, in favor of using explicit waits only. FluentLenium hides the
complexity of explicit waits so them become readable when invoked manually, and can even automate them before each
action with the
@Wait hook so you don’t have to care about them.
withDefaultSearchWaithas been removed. Use
Something wrong ?
You may open issue if something wrong occurs during migration.