Git Product home page Git Product logo

selenium.webdriver.extensions's Introduction

.NET codecov Quality Gate Status

Description

Extensions for Selenium WebDriver including jQuery/Sizzle selector support.

Features

Main

  • Support for nested selectors
  • Easy setup: install NuGet package and start using it with your existing Selenium solution
  • High quality ensured by continuous integration setup with Appveyor, unit and integration tests and high code coverage
  • Well documented code using GitBook

jQuery/Sizzle support

  • jQuery/Sizzle selectors support for Selenium WebDriver
  • jQuery/Sizzle auto-load on pages on sites that don't use jQuery
  • Support for context switching
  • Support for ExpectedConditions
  • Support for Page Objects

Installation

Run the following command in Visual Studio Package Manager Console.

Install-Package Selenium.WebDriver.Extensions

Documentation

API documentation can be found on GitBook and user guide is on the wiki.

Usage

Include extensions

Create alias for the extension By to be used.

using By = Selenium.WebDriver.Extensions.By;

If you don't want to override the By to be used, you can always create JQuerySelector and SizzleSelector instances with new keyword.

Basic jQuery example

Invoke jQuery selectors on the WebDriver.

driver.FindElements(By.JQuerySelector("input:visible"))

jQuery Traversing methods

You can also chain jQuery traversing methods.

var selector = By.JQuerySelector("div.myclass").Parents(".someClass").NextAll();
driver.FindElement(selector);

jQuery loading

If the site that you are testing with Selenium does not include jQuery this extension will automatically load the 3.5.1 version when you run any of the Find* methods. If you want you can choose to load a different version of jQuery. The library uses jQuery CDN by default, but if you want to use a completely different source, that's also supported

driver.LoadJQuery("1.11.0"); // load specific version from default CDN
driver.LoadJQuery(new Uri("https://some.server/jquery.js")); // load a library from other source

jQuery variable name

When you create a jQuery selector using By helper class the resulting selector will use jQuery as library variable name. If you site is using a different variable name for this purpose you can pass this value as an optional parameter.

var selector = By.JQuerySelector("div", jQueryVariable: "myJQuery");

jQuery context switch

You can use one JQuerySelector instance as a context of another JQuerySelector.

var context = By.JQuerySelector("div.myClass");
var selector = By.JQuerySelector("ol li", context);
driver.FindElements(selector);

Basic Sizzle example

Invoke Sizzle selectors on the WebDriver.

driver.FindElements(By.SizzleSelector("input:visible"))

Sizzle loading

If the site that you are testing with Selenium does not include Sizzle this extension will automatically load the 2.0.0 version when you run any of the Find* methods. If you want you can choose to load a different version of Sizzle. The library used CloudFlare CDN by default, but if you want to use a completely different source, that's also supported

driver.LoadSizzle("1.11.1"); // load specific version from default CDN
driver.LoadSizzle(new Uri("https://some.server/sizzle.js")); // load a library from other source

Sizzle context switch

You can use one SizzleSelector instance as a context of another SizzleSelector. Contrary to jQuery equivalent of this method, only first element from the context is used. This is because it's a limitation of Sizzle.

var context = By.SizzleSelector("div.myClass");
var selector = By.SizzleSelector("ol li", context);
driver.FindElements(selector);

selenium.webdriver.extensions's People

Contributors

rayell 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.