IntelliTect.TestTools.Selenate 3.0.0

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package IntelliTect.TestTools.Selenate --version 3.0.0                
NuGet\Install-Package IntelliTect.TestTools.Selenate -Version 3.0.0                
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="IntelliTect.TestTools.Selenate" Version="3.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add IntelliTect.TestTools.Selenate --version 3.0.0                
#r "nuget: IntelliTect.TestTools.Selenate, 3.0.0"                
#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 IntelliTect.TestTools.Selenate as a Cake Addin
#addin nuget:?package=IntelliTect.TestTools.Selenate&version=3.0.0

// Install IntelliTect.TestTools.Selenate as a Cake Tool
#tool nuget:?package=IntelliTect.TestTools.Selenate&version=3.0.0                

Selenate

Provides wrapper functions to leverage commonly used WebDriverWaits. Note that this does not provide exhaustive functionality, and customer WebDriverWaits will still be needed for complex or unique scenarios.

Simple Usage

To instantiate a class that manages simple WebDriver interactions:

// WebDriverFactory is not required. You can pass in your own IWebDriver to DriverHandler instead.
IWebDriver driver = new WebDriverFactory(BrowserType.Chrome).GetDriver();
DriverHandler handler = new(driver);
handler.NavigateToPage("http://www.some-page.com/");

To instantiate a class that manages simple interactions with a single IWebElement (note: this uses a Page Object Model approach):

public class SomePageUnderTest
{
    public SomePageUnderTest(IWebDriver driver)
    {
        _Driver = driver;
    }

    // Note that this will not save any settings (e.g. StartButton.SetTimeoutSeconds(30)) made after object instantiation.
    // Use an explicit getter with a private backing field for that.
    public ElementHandler SomeButton => new (_Driver, By.CssSelector("div[id='someId']"));

    private IWebDriver _Driver;
}

public class SomeTest
{
    public SomeTest()
    {
        IWebDriver driver = new WebDriverFactory(BrowserType.Chrome).GetDriver();
        _Handler = new(driver);
    }

    private DriverHandler _Handler;

    // Also works with other runners like MSTest and NUnit
    [Fact]
    public void Testing()
    {
        // Arrange
        SomePageUnderTest put = new(_Handler.WrappedDriver);
        _Handler.NavigateToPage("http://www.some-page.com/");

        // Act
        // Below automatically waits for the element to exist and be clickable before executing.
        put.SomeButton.Click();

        // Assert (pretend the button disappears after clicking it.)
        // Default timeout is 15s. Override for this call.
        Assert.True(put.SomeButton.SetTimeoutSeconds(5).WaitForNotDisplayed(),
            "The button did not disappear within 5s after clicking it.");
    }
}

Complex Use Cases

Using the same structure as above, we can create complex use cases

public void SomeTest
{
    // Same setup as above.

    // Also works with other runners like MSTest and NUnit
    [Fact]
    public void SomeOtherTest()
    {
        // Arrange
        // Note: to reduce code duplication, this can be abstracted out into the Page Object for small projects,
        // Or into an explicit class of grouped actions for large projects.
        SomePageUnderTest put = new(_Handler.WrappedDriver);
        _Handler.NavigateToPage("http://www.some-page.com/");

        // Act and Assert
        // Sometimes the site is slow to load, and the initial click doesn't do anything.
        // For whatever reason, dev team won't fix.

        WebDriverWait wait = new(_Handler.WrappedDriver, TimeSpan.FromSeconds(30));
        wait.IgnoreExceptionTypes(
            typeof(NoSuchElementException),
            typeof(InvalidElementStateException),
            typeof(ElementNotVisibleException),
            typeof(StaleElementReferenceException),
            typeof(ElementClickInterceptedException));
        
        // If the button continues to be displayed once the 30s timeout is reached,
        // This will throw a WebDriverTimeout exception.
        // Note: if you want a friendly assert message,
        //   you can wrap just this block of code in a try/catch(WebDriverException) and selectively assign a variable true or false / assert on the result.
        // Best practice in that scenario is to abstract out to a harness page object or group action object as soon as a second instance of this pattern is used.
        wait.Until(x => x
        {
            IWebElement someButton = x.FindElement(put.SomeButton.Locator);
            someButton.Click();
            return !someButton.Displayed;
        })
    }
}
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 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 (1)

Showing the top 1 NuGet packages that depend on IntelliTect.TestTools.Selenate:

Package Downloads
IntelliTect.TestTools.SelenateExtensions

A set of classes for doing a default implementation of Selenate, which is a wrapper for interacting with Selenium in a way that makes calls more reliable than the basic implementation of Selenium

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.1.0-alpha-2 248 12/11/2023
3.1.0-alpha-1 180 11/3/2023
3.0.0 491 3/29/2023
2.1.0 20,386 9/28/2021
2.0.0 3,406 6/23/2021
1.4.0 497 5/11/2021
1.3.3 10,950 1/7/2021
1.3.2 640 7/23/2020
1.3.1 705 3/4/2020
1.3.0 17,297 2/4/2020
1.2.2 2,514 7/19/2019
1.2.1 584 7/17/2019
1.2.0 595 7/5/2019
1.1.0 5,518 1/22/2019
1.0.3 801 11/12/2018