Giter Site home page Giter Site logo

da-sergey-obruch / htmlelements Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yandex-qatools/htmlelements

0.0 1.0 0.0 854 KB

Html Elements is a Java framework providing easy-to-use way of interaction with web-page elements in web-page tests.

Home Page: http://htmlelements.qatools.ru

License: Other

Java 100.00%

htmlelements's Introduction

Html Elements framework

release Maven Central

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 and Samples for more details.

You can ask your questions on StackOverflow with htmlelements tag.

Other Languages

In case you are non-java guy, don't panic, there are still few options:

Release Notes

Include Html Elements in your project

Maven dependencies for Html Elements core:

<dependency>
    <groupId>ru.yandex.qatools.htmlelements</groupId>
    <artifactId>htmlelements-java</artifactId>
    <version>1.15</version>
</dependency>

And for Thucydides integration:

<dependency>
    <groupId>ru.yandex.qatools.htmlelements</groupId>
    <artifactId>htmlelements-thucydides</artifactId>
    <version>1.15</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.15</version>
</dependency>

Since 1.15 it requires Java 8. Please use 1.14 for Java 7 support.

Create blocks of elements

For example, let's create a block for the search form on the page http://www.yandex.com:

@Name("Search form")
@FindBy(xpath = "//form")
public class SearchArrow extends HtmlElement {
    @Name("Search request input")
    @FindBy(id = "searchInput")
    private TextInput requestInput;

    @Name("Search button")
    @FindBy(className = "b-form-button__input")
    private Button searchButton;

    public void search(String request) {
        requestInput.sendKeys(request);
        searchButton.click();
    }
}

Construct page object using created blocks

You can easily use created blocks in page objects:

public class SearchPage {
    private SearchArrow searchArrow;
    // Other blocks and elements here

    public SearchPage(WebDriver driver) {
        PageFactory.initElements(new HtmlElementDecorator(driver), this);
    }

    public void search(String request) {
        searchArrow.search(request);
    }

    // Other methods here
}

Use page objects in your tests

Created page objects can be used in your tests. This makes tests more concise and easy to write.

public class SampleTest {
    private WebDriver driver = new FirefoxDriver();
    private SearchPage searchPage = new SearchPage(driver);

    @Before
    public void loadPage() {
        driver.get("http://www.yandex.com");
    }

    @Test
    public void sampleTest() {
        searchPage.search("yandex");
        // Some assertion here
    }

    @After
    public void closeDriver() {
        driver.quit();
    }
}

Questions?

In case you can't find an answer in documentation and examples provided above, you can ask it on StackOverflow with htmlelements tag.

htmlelements's People

Contributors

alexandertolmachev avatar alkedr avatar artkoshelev avatar emaks avatar eroshenkoam avatar ham1 avatar ilya-murzinov avatar lanwen avatar p0deje avatar proxeter avatar qatools-ci avatar yumauri avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.