-
Notifications
You must be signed in to change notification settings - Fork 10
Sizzle Extensions
Sizzle is a selector engine which jQuery uses for finding elements but it can be used also without jQuery. Selenium.WebDriver.Extensions.Sizzle
library constains the implementation of Sizzle selector that allows to run Sizzle-based searches on Selenium. To have access to Sizzle selector you need to reference the proper By
class. The easiest method to do that is by adding following directive.
using By = Selenium.WebDriver.Extensions.Sizzle.By;
You can then use Sizzle selectors in a similar way as build-in Selenium selectors.
var result = driver.FindElement(By.SizzleSelector("div:visible"));
If you don't want to override the By
instance with using
statement, you can still perform the search by creating SizzleSelector
objects manually.
var result = driver.FindElement(new SizzleSelector("div:visible"));
The library can detect whether Sizzle has been loaded on the page being tested and if it's not present it will be automatically loaded. However you can also control which version of the Sizzle to use or even provide your own source for the Sizzle library which can be useful if you run tests on a machine that doesn't have access to internet.
// loads given version
driver.LoadSizzle("2.1.1");
// loads given library from URL
driver.LoadSizzle(new Uri("http://myserver.com/sizzle-2.1.1.min.js"));
Using the library
Extending the library