Table of Contents

Class RelativeBy

Namespace
OpenQA.Selenium
Assembly
WebDriver.dll

Provides a mechanism for finding elements spatially relative to other elements.

public class RelativeBy : By
Inheritance
RelativeBy
Inherited Members

Constructors

RelativeBy()

Prevents a default instance of the RelativeBy class.

protected RelativeBy()

Methods

Above(By)

Locates an element above the specified element.

public RelativeBy Above(By locator)

Parameters

locator By

The locator describing the element to look above for elements.

Returns

RelativeBy

A RelativeBy object for use in finding the elements.

Above(IWebElement)

Locates an element above the specified element.

public RelativeBy Above(IWebElement element)

Parameters

element IWebElement

The element to look above for elements.

Returns

RelativeBy

A RelativeBy object for use in finding the elements.

Below(By)

Locates an element below the specified element.

public RelativeBy Below(By locator)

Parameters

locator By

The locator describing the element to look below for elements.

Returns

RelativeBy

A RelativeBy object for use in finding the elements.

Below(IWebElement)

Locates an element below the specified element.

public RelativeBy Below(IWebElement element)

Parameters

element IWebElement

The element to look below for elements.

Returns

RelativeBy

A RelativeBy object for use in finding the elements.

FindElement(ISearchContext)

Finds the first element matching the criteria.

public override IWebElement FindElement(ISearchContext context)

Parameters

context ISearchContext

An ISearchContext object to use to search for the elements.

Returns

IWebElement

The first matching IWebElement on the current context.

FindElements(ISearchContext)

Finds all elements matching the criteria.

public override ReadOnlyCollection<IWebElement> FindElements(ISearchContext context)

Parameters

context ISearchContext

An ISearchContext object to use to search for the elements.

Returns

ReadOnlyCollection<IWebElement>

A ReadOnlyCollection<T> of all WebElements matching the current criteria, or an empty list if nothing matches.

LeftOf(By)

Locates an element to the left of the specified element.

public RelativeBy LeftOf(By locator)

Parameters

locator By

The locator describing the element to look to the left of for elements.

Returns

RelativeBy

A RelativeBy object for use in finding the elements.

LeftOf(IWebElement)

Locates an element to the left of the specified element.

public RelativeBy LeftOf(IWebElement element)

Parameters

element IWebElement

The element to look to the left of for elements.

Returns

RelativeBy

A RelativeBy object for use in finding the elements.

Near(By)

Locates an element near the specified element.

public RelativeBy Near(By locator)

Parameters

locator By

The locator describing the element to look near for elements.

Returns

RelativeBy

A RelativeBy object for use in finding the elements.

Near(By, int)

Locates an element near the specified element.

public RelativeBy Near(By locator, int atMostDistanceInPixels)

Parameters

locator By

The locator describing the element to look near for elements.

atMostDistanceInPixels int

The maximum distance from the element to be considered "near."

Returns

RelativeBy

A RelativeBy object for use in finding the elements.

Near(IWebElement)

Locates an element near the specified element.

public RelativeBy Near(IWebElement element)

Parameters

element IWebElement

The element to look near for elements.

Returns

RelativeBy

A RelativeBy object for use in finding the elements.

Near(IWebElement, int)

Locates an element near the specified element.

public RelativeBy Near(IWebElement element, int atMostDistanceInPixels)

Parameters

element IWebElement

The element to look near for elements.

atMostDistanceInPixels int

The maximum distance from the element to be considered "near."

Returns

RelativeBy

A RelativeBy object for use in finding the elements.

RightOf(By)

Locates an element to the right of the specified element.

public RelativeBy RightOf(By locator)

Parameters

locator By

The locator describing the element to look to the right of for elements.

Returns

RelativeBy

A RelativeBy object for use in finding the elements.

RightOf(IWebElement)

Locates an element to the right of the specified element.

public RelativeBy RightOf(IWebElement element)

Parameters

element IWebElement

The element to look to the right of for elements.

Returns

RelativeBy

A RelativeBy object for use in finding the elements.

WithLocator(By)

Creates a new RelativeBy for finding elements with the specified tag name.

public static RelativeBy WithLocator(By by)

Parameters

by By

A By object that will be used to find the initial element.

Returns

RelativeBy

A RelativeBy object to be used in finding the elements.