[]
(https://github.com/yandex-qatools/htmlelements/releases/latest)
[
]
(https://maven-badges.herokuapp.com/maven-central/ru.yandex.qatools.htmlelements/htmlelements-java)
This framework is designed to provide an easy-to-use way of interacting with web-page elements in your tests. It can be considered to be an extension of WebDriver Page Object.
With the help of the Html Elements framework you can group web-page elements into blocks, encapsulate logic of interaction within them and then easily use created blocks in page objects. It also provides a set of helpful matchers to use with web-page elements and blocks. See [JavaDocs] (https://oss.sonatype.org/service/local/repositories/releases/archive/ru/yandex/qatools/htmlelements/htmlelements-java/1.16/htmlelements-java-1.16-javadoc.jar/!/index.html) and Samples for more details.
You can ask your questions on StackOverflow with the [![htmlelements] (https://img.shields.io/badge/stackoverflow-htmlelements-orange.svg?style=flat)] (http://stackoverflow.com/questions/tagged/htmlelements) tag.
In case you are not a Java guy/gal, don't panic, there are still few options:
- Html Elements .NET implementation - .NET port made by Vadzim Hushchanskou
- Html Elements PHP implementation - PHP port made by Alexander Obuhovich
- bumblebee framework (C#) - same idea, nice implementation
- Version 1.17 Release Notes
- Version 1.16 Release Notes
- Version 1.15 Release Notes
- Version 1.14 Release Notes
- Version 1.13 Release Notes
- Version 1.12 Release Notes
- Version 1.11 Release Notes
- Version 1.10 Release Notes
- Version 1.9 Release Notes
Maven dependencies for Html Elements core:
<dependency>
<groupId>ru.yandex.qatools.htmlelements</groupId>
<artifactId>htmlelements-java</artifactId>
<version>1.17</version>
</dependency>And for Thucydides integration:
<dependency>
<groupId>ru.yandex.qatools.htmlelements</groupId>
<artifactId>htmlelements-thucydides</artifactId>
<version>1.17</version>
</dependency>Or you can include all modules at once if needed:
<dependency>
<groupId>ru.yandex.qatools.htmlelements</groupId>
<artifactId>htmlelements-all</artifactId>
<version>1.17</version>
</dependency>Since 1.15 Java 8 is required. Please use 1.14 for Java 7 support.
For example, let's create a block for the search form on the page http://www.yandex.com:
@Name("Search form")
@FindBy(xpath = "//form")
publicclassSearchArrowextendsHtmlElement {
@Name("Search request input")
@FindBy(id = "searchInput")
privateTextInputrequestInput;
@Name("Search button")
@FindBy(className = "b-form-button__input")
privateButtonsearchButton;
publicvoidsearch(Stringrequest) {
requestInput.sendKeys(request);
searchButton.click();
}
}You can easily use created blocks in page objects:
publicclassSearchPage {
privateSearchArrowsearchArrow;
// Other blocks and elements here ...publicSearchPage(WebDriverdriver) {
PageFactory.initElements(newHtmlElementDecorator(newHtmlElementLocatorFactory(driver)), this);
}
publicvoidsearch(Stringrequest) {
searchArrow.search(request);
}
// Other methods here ...
}Created page objects can be used in your tests. This makes tests more concise, easier to maintain, and easy to write.
publicclassSampleTest {
privateWebDriverdriver = newFirefoxDriver();
privateSearchPagesearchPage = newSearchPage(driver);
@BeforepublicvoidloadPage() {
driver.get("http://www.yandex.com");
}
@TestpublicvoidsampleTest() {
searchPage.search("yandex");
// Some assertion here
}
@AfterpublicvoidcloseDriver() {
driver.quit();
}
}In case you can't find an answer in documentation and examples provided above, you can ask it on StackOverflow with the
tag.