• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

yandex-qatools/htmlelements: Html Elements is a Java framework providing easy-to ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

yandex-qatools/htmlelements

开源软件地址:

https://github.com/yandex-qatools/htmlelements

开源编程语言:

Java 100.0%

开源软件介绍:

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 the htmlelements tag.

Other Languages

In case you are not a Java guy/gal, 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.21.0</version> <!-- 1.21+ is SELENIUM 4.1.0 compatible -->
</dependency>

And for Thucydides integration:

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

Since 1.15 Java 8 is required. 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(new HtmlElementLocatorFactory(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, easier to maintain, 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 the htmlelements tag.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Sponsor @jgthms on GitHub Sponsors · GitHub发布时间:2022-06-18
下一篇:
nolanw/HTMLReader: A WHATWG-compliant HTML parser in Objective-C.发布时间:2022-06-17
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap