HtmlElements 4.0.0-alpha

This is a prerelease version of HtmlElements.
There is a newer version of this package available.
See the version list below for details.
dotnet add package HtmlElements --version 4.0.0-alpha                
NuGet\Install-Package HtmlElements -Version 4.0.0-alpha                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="HtmlElements" Version="4.0.0-alpha" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add HtmlElements --version 4.0.0-alpha                
#r "nuget: HtmlElements, 4.0.0-alpha"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install HtmlElements as a Cake Addin
#addin nuget:?package=HtmlElements&version=4.0.0-alpha&prerelease

// Install HtmlElements as a Cake Tool
#tool nuget:?package=HtmlElements&version=4.0.0-alpha&prerelease                

HtmlElements is .NET library complementing to Selenium WebDriver page object model by allowing you to create more complex and sophysticated page objects. It also provides set of standard page objects for commonly used HTML elements (links, input fields, images, frames, etc), alternative wait syntax, smart frames and some other usefull utilities. You can add it to your project by installing HtmlElements nuget package. More information can be found in API reference.

Web components

The main goal of HtmlElements library is to represent any given page or part of a page as set of smaller reusable components. Every component is a class having any number of nested components and public methods. Smaller components create a hierarchy similar to DOM with a page component at the top.

Assuming we would like to model a page listing nuget packages (https://www.nuget.org/packages) we could describe every package from list as a separate component and then have list of such components inside page object describing page as a whole.

public class NugetPackageListPage {
    
    [FindsBy(How = How.CssSelector, Using = "#searchBoxInput"), CacheLookup]
    private IWebElement _searchInput;

    [FindsBy(How = How.CssSelector, Using = "#searchBoxSubmit"), CacheLookup]
    private IWebElement _searchBtn;

    public IList<NugetPackageItem> Packages { get; private set; }

    public void Search(String query){
        _searchInput.EnterText(query);
        _searchBtn.Click();
    }

}

[CacheLookup]
[ElementLocator(How = How.CssSelector, Using = "#searchResults li")]
public class NugetPackageItem : HtmlElement {

    [FindsBy(How = How.CssSelector, Using = "h1>a"), CacheLookup]
    private HtmlElement _name;

    [FindsBy(How = How.CssSelector, Using = "article>p:nth-child(2)"), CacheLookup]
    private HtmlElement _description;

    [FindsBy(How = How.CssSelector, Using = ".downloads"), CacheLookup]
    private HtmlElement _downloads;
    
    public String Name { 
        get {
            return _name.Text;
        }
    }

    public String Description {
        get {
            return _description.Text;
        }
    }

    public String Downloads {
        get {
            return _downloads.Text;
        }
    }
}

IWebDriver webDriver = new FirefoxDriver();

IPageObjectFactory pageFactory = new PageObjectFactory();

NugetPackageListPage page = pageFactory.Create<NugetPackageListPage>(webDriver);

PageObjectFactory is creating and initializing page objects. It is one of the core library components since it creates and recursively initializes all page objects in a given hierarchy. Page factory can initialize fields and properties which type is derived from IWebElement or IList<IWebElement>. It can create (and initialize) page object of any type using default or custom constructor. It also provides few extension points.

Default page factory implementation wraps raw WebElements located in browser into proxy loading elements on demand and handling StaleElementReferenceException by reloading the underlying element. It is possible to change how proxy is being created by implementing IProxyFactory interface and how elements are loaded by implementing ILoaderFactory interface. Also it is possible to change the way how new page objects are being instantiated by overriding CreatePageObjectInstance default factory method and how page object members are being initialized by overriding CreateMemberInstance method.

Please refer to API reference for more details.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
4.0.0 140,820 10/19/2021
4.0.0-alpha 3,919 1/30/2021
3.2.0 48,504 5/30/2020
3.1.0 1,222 5/30/2020
3.0.1 43,430 11/30/2017
3.0.0 5,586 9/16/2017
2.0.4 1,984 8/10/2017
2.0.3 2,258 8/14/2016
2.0.2-alpha 1,761 2/9/2016
2.0.1 2,641 3/9/2016
2.0.0 1,730 2/15/2016
1.1.0.10 2,178 12/11/2015
1.1.0.9 1,885 6/10/2015
1.1.0.8 2,007 11/20/2014
1.1.0.7 1,916 4/30/2014
1.1.0.6 1,919 4/10/2014
1.1.0.5 1,876 12/5/2013
1.1.0.4 1,771 12/5/2013
1.1.0.3 1,866 12/3/2013
1.1.0.2 1,765 12/3/2013
1.1.0.1 1,777 12/1/2013
1.1.0 1,944 11/29/2013

4.0.0
           - use selenium 4.0-alpha
           - use PageObjectFactory from SeleniumExtras.PageObjects
           - introduce ElementLocatorAttribute
           3.2.0:
           - target netstandard
           3.1.0:
           - deprecate `SwitchToLastOpenedWindow` extension method
           - update methods waiting for opening tabs to return opened window handles
           3.0.1:
           - update selenium references to 3.7.0
           - update 'PreviousSibling', 'NextSibling', 'FirstChild', 'LastChild' properties to return only element nodes
           3.0.0:
           - update selenium reference to 3.5.2
           - add NextSibling WebElement property
           2.0.2:
           - handle InvalidOperationException thrown by IOS when element was not found in cache
           2.0.1:
           - unwrap raw WebElement from multilayered wrapper during FrameContextOverride initialization
           2.0.0:
           - page object factory rewritten from scratches: now it has interface, default implementation and better documentation
           - redesing element groups and removed extension method used for getting elements from a group
           - added page factory property to custom elements
           - added documentation for most public members