By
The By
class is usually used as a factory for all sorts of selenium Selectors. Each type of the selector supported by Selenium can be created by a specific static method in this class. SWE is also following this concept by providing a custom version of the By
class that can create all Selenium selector types but it also can create new types of selectors that are provided in this library.
By alias
The easiest way of creating selectors in Selenium WebDriver is by using By
static class members. Since in C# static class cannot be inherited, another version of this class has been created that exposes new types of selectors apart from the ones provided by Selenium WebDriver.
The most convenient way of using this class is by specifying the alias.
By.JQuerySelector
Gets a mechanism to find elements matching jQuery selector.
By.SizzleSelector
Gets a mechanism to find elements matching Sizzle selector.
By.ClassName
Gets a mechanism to find elements by their CSS class.
By.CssSelector
Gets a mechanism to find elements by their cascading style sheet (CSS) selector.
By.Id
Gets a mechanism to find elements by their ID.
By.Name
Gets a mechanism to find elements by their name.
By.TagName
Gets a mechanism to find elements by their tag name.
By.LinkText
Gets a mechanism to find elements by their link text.
By.PartialLinkText
Gets a mechanism to find elements by a partial match on their link text.
By.XPath
Gets a mechanism to find elements by an XPath query. When searching within a IWebElement
using xpath be aware that IWebDriver
follows standard conventions: a search prefixed with /
will search the entire document, not just the children of this current node. Use ./
to limit your search to the children of this IWebElement
.
Last updated
Was this helpful?