Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/softlr/selenium.webdriver.extensions
Extensions for Selenium WebDriver including jQuery/Sizzle selector support.
https://github.com/softlr/selenium.webdriver.extensions
jquery selectors selenium selenium-webdriver sizzle
Last synced: about 1 month ago
JSON representation
Extensions for Selenium WebDriver including jQuery/Sizzle selector support.
- Host: GitHub
- URL: https://github.com/softlr/selenium.webdriver.extensions
- Owner: Softlr
- License: apache-2.0
- Created: 2014-07-07T05:13:09.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2022-04-05T21:00:26.000Z (over 2 years ago)
- Last Synced: 2024-11-22T03:09:24.767Z (about 1 month ago)
- Topics: jquery, selectors, selenium, selenium-webdriver, sizzle
- Language: C#
- Homepage:
- Size: 13.9 MB
- Stars: 49
- Watchers: 8
- Forks: 10
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![.NET](https://github.com/Softlr/Selenium.WebDriver.Extensions/actions/workflows/dotnet.yml/badge.svg)
[![codecov](https://codecov.io/gh/Softlr/Selenium.WebDriver.Extensions/branch/develop/graph/badge.svg?token=LNpg4sX17h)](https://codecov.io/gh/Softlr/Selenium.WebDriver.Extensions)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=selenium.webdriver.extensions&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=selenium.webdriver.extensions)# 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](https://app.gitbook.com/@softlr/s/selenium-webdriver-extensions/)
## 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.
```posh
Install-Package Selenium.WebDriver.Extensions
```# Documentation
API documentation can be found on [GitBook](https://app.gitbook.com/@softlr/s/selenium-webdriver-extensions/) and user guide is on the [wiki](https://github.com/Softlr/Selenium.WebDriver.Extensions/wiki).# Usage
#### Include extensions
Create alias for the extension `By` to be used.
```csharp
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.
```csharp
driver.FindElements(By.JQuerySelector("input:visible"))
```#### jQuery Traversing methods
You can also chain jQuery traversing methods.
```csharp
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```csharp
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.```csharp
var selector = By.JQuerySelector("div", jQueryVariable: "myJQuery");
```#### jQuery context switch
You can use one `JQuerySelector` instance as a context of another `JQuerySelector`.```csharp
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.
```csharp
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```csharp
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.```csharp
var context = By.SizzleSelector("div.myClass");
var selector = By.SizzleSelector("ol li", context);
driver.FindElements(selector);
```