Skip to content

selenium.locator

Element locators pairing a W3C location strategy with a selector.

By

struct By;

A W3C location strategy paired with the selector value to match against.

using

string using;

The location strategy name sent as the using field.

value

string value;

The selector expression interpreted according to using.

this

this(string using, string value);

Constructs a locator.

Parameters:

Name Description
string using The W3C location strategy name.
string value The selector expression.

Throws: InvalidSelectorException if the strategy is unknown, the value is empty, or an XPath value has unbalanced delimiters.

css

static By css(string value);

Locates elements by CSS selector.

Throws: InvalidSelectorException if value is empty.

tagName

static By tagName(string value);

Locates elements by tag name.

Throws: InvalidSelectorException if value is empty.

linkText

static By linkText(string value);

Locates anchors whose visible text equals the value.

Throws: InvalidSelectorException if value is empty.

partialLinkText

static By partialLinkText(string value);

Locates anchors whose visible text contains the value.

Throws: InvalidSelectorException if value is empty.

xpath

static By xpath(string value);

Locates elements by XPath expression.

Throws: InvalidSelectorException if value is empty or has unbalanced delimiters.

toJSON

JSONValue toJSON();

Serializes the strategy into the {using, value} locator payload.

Returns: The locator payload.