GithubHelp home page GithubHelp logo

nazarmartin / selenium.htmlelements.net Goto Github PK

View Code? Open in Web Editor NEW

This project forked from eger-geger/selenium.htmlelements.net

0.0 2.0 0.0 14.65 MB

Elements model for Selenium.WebDriver

License: Other

C# 100.00%

selenium.htmlelements.net's Introduction

Can be installed with nuget HtmlElements

Define your custom element

internal class Pagination : HtmlElement {

    public Pagination(IWebElement wrapped) : base(wrapped) {}

    [FindsBy(How = How.CssSelector, Using = ".value.rating")]
    private HtmlElement _currentPageNumber;

    [FindsBy(How = How.CssSelector, Using = ".nextPage")]
    private HtmlLink _nextPageLink;

    public int CurrentNumber {
        get { return int.Parse(_currentPageNumber.Text); }
    }

    public DevLifePage OpenNextPage() {
        return _nextPageLink.Open<DevLifePage>();
    }
  
}

and use it within page or other element

internal class DevLifePage : HtmlPage {

    [FindsBy(How = How.CssSelector, Using = ".jslink:nth-child(1)")]
    private HtmlLink _sortByDate;

    [FindsBy(How = How.CssSelector, Using = ".jslink:nth-child(3)")]
    private HtmlLink _sortByHottest;

    [FindsBy(How = How.CssSelector, Using = ".jslink:nth-child(2)")]
    private HtmlLink _sortByRatig;

    [FindsBy(How = How.CssSelector, Using = ".entry")]
    public DevLifePost Posts { get; private set; }

    public DevLifePage(ISearchContext wrapped) : base(wrapped) {}

    [FindsBy(How = How.CssSelector, Using = ".pagination")]
    public Pagination Pagination { get; private set; }

    public void SortByDate() {
        _sortByDate.Click();
    }

    public void SortByRating() {
        _sortByRatig.Click();
    }

    public void SortByHottest() {
        _sortByHottest.Click();
    }

}

Finally apply ElementActivator to your page

var devLifePage = ElementActivator.Activate<DevLifePage>(new FirefoxDriver());

Also you are welcome to try some of predefined elements and add some more to them!

selenium.htmlelements.net's People

Watchers

James Cloos avatar  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.