Skip navigation links

Package hu.ibello.expect

This package contains interfaces used in different expectations.

See: Description

Package hu.ibello.expect Description

This package contains interfaces used in different expectations.

Ibello Expectation Engine

During an expectation the program waits until a specific property of the examined entity changes or the time runs out. If the change occurs, the expectation will success and the test execution continues. If the time runs out, an exception will be thrown, every important information will be logged and the current test will fail. It means that the test execution will stop and the next test will be started.

The examined entity can be an element on the page, a collection of elements, or the browser itself.

The timeout of an expectation cannot be specified directly with a numeric value. All timeouts should be defined in the ibello configuration, with "ibello.timeout." prefix. The unit should be seconds. During the expectation, only the key of the timeout can be specified - it is the other half of the configuration property, after the "ibello.timeout." prefix. With this rule we can manage our timeout values in a more secure and general way, and can change them in different test execution environment easily.

The center interface of the expectation engine is the ExpectationBuilder. It contains fluent methods to construct and run an expectation. This interface is available only in page objects - see PageObject.expectations() method.

An expectation can be "hard" or "soft". If a "hard" expectation fails, the execution of the current test is instantly terminated. This is the difference from "soft" expectations, where the test execution continues, but at the end the test itself will be marked as failed. "Hard" expectations can be constructed with the expect(...) methods. For "soft" expectations, the assume(...) methods can be used.

Examples (in a page object):

 WebElement button = ...;
 WebElements inputFields = ...;
 
 expectations().assume(button).toHave().text("Click me");
 expectations().expect(button).toBe().clickable();
 expectations().expect(inputFields).toHave().size(3);
 expectations().expect(browser()).toHave().url("ibello.com");
 expectations().any(() -> {
     expectations().expect(button).toBe().clickable();
     expectations().expect(inputFields).toHave().size(3);
     expectations().expect(browser()).toHave().url("ibello.com");
 });
 
Author:
Kornél Simon
Skip navigation links

Created by Kornél Simon, 2022