Class RelativeBy
Provides a mechanism for finding elements spatially relative to other elements.
public sealed class RelativeBy : By
- Inheritance
-
RelativeBy
- Inherited Members
Methods
Above(By)
Locates an element above the specified element.
public RelativeBy Above(By locator)
Parameters
locator
ByThe locator describing the element to look above for elements.
Returns
- RelativeBy
A RelativeBy object for use in finding the elements.
Exceptions
- ArgumentNullException
If
locator
is null.
Above(IWebElement)
Locates an element above the specified element.
public RelativeBy Above(IWebElement element)
Parameters
element
IWebElementThe element to look above for elements.
Returns
- RelativeBy
A RelativeBy object for use in finding the elements.
Exceptions
- ArgumentNullException
If
element
is null.
Below(By)
Locates an element below the specified element.
public RelativeBy Below(By locator)
Parameters
locator
ByThe locator describing the element to look below for elements.
Returns
- RelativeBy
A RelativeBy object for use in finding the elements.
Exceptions
- ArgumentNullException
If
locator
is null.
Below(IWebElement)
Locates an element below the specified element.
public RelativeBy Below(IWebElement element)
Parameters
element
IWebElementThe element to look below for elements.
Returns
- RelativeBy
A RelativeBy object for use in finding the elements.
Exceptions
- ArgumentNullException
If
element
is null.
FindElement(ISearchContext)
Finds the first element matching the criteria.
public override IWebElement FindElement(ISearchContext context)
Parameters
context
ISearchContextAn ISearchContext object to use to search for the elements.
Returns
- IWebElement
The first matching IWebElement on the current context.
Exceptions
- ArgumentException
If
context
is not IJavaScriptExecutor or wraps a driver that does.
FindElements(ISearchContext)
Finds all elements matching the criteria.
public override ReadOnlyCollection<IWebElement> FindElements(ISearchContext context)
Parameters
context
ISearchContextAn 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.
Exceptions
- ArgumentException
If
context
is not IJavaScriptExecutor or wraps a driver that does.
LeftOf(By)
Locates an element to the left of the specified element.
public RelativeBy LeftOf(By locator)
Parameters
locator
ByThe locator describing the element to look to the left of for elements.
Returns
- RelativeBy
A RelativeBy object for use in finding the elements.
Exceptions
- ArgumentNullException
If
locator
is null.
LeftOf(IWebElement)
Locates an element to the left of the specified element.
public RelativeBy LeftOf(IWebElement element)
Parameters
element
IWebElementThe element to look to the left of for elements.
Returns
- RelativeBy
A RelativeBy object for use in finding the elements.
Exceptions
- ArgumentNullException
If
element
is null.
Near(By)
Locates an element near the specified element.
public RelativeBy Near(By locator)
Parameters
locator
ByThe locator describing the element to look near for elements.
Returns
- RelativeBy
A RelativeBy object for use in finding the elements.
Exceptions
- ArgumentNullException
If
locator
is null.
Near(By, int)
Locates an element near the specified element.
public RelativeBy Near(By locator, int atMostDistanceInPixels)
Parameters
locator
ByThe locator describing the element to look near for elements.
atMostDistanceInPixels
intThe maximum distance from the element to be considered "near."
Returns
- RelativeBy
A RelativeBy object for use in finding the elements.
Exceptions
- ArgumentNullException
If
locator
is null.- ArgumentOutOfRangeException
If
atMostDistanceInPixels
is not a positive value.
Near(IWebElement)
Locates an element near the specified element.
public RelativeBy Near(IWebElement element)
Parameters
element
IWebElementThe element to look near for elements.
Returns
- RelativeBy
A RelativeBy object for use in finding the elements.
Exceptions
- ArgumentNullException
If
element
is null.
Near(IWebElement, int)
Locates an element near the specified element.
public RelativeBy Near(IWebElement element, int atMostDistanceInPixels)
Parameters
element
IWebElementThe element to look near for elements.
atMostDistanceInPixels
intThe maximum distance from the element to be considered "near."
Returns
- RelativeBy
A RelativeBy object for use in finding the elements.
Exceptions
- ArgumentNullException
If
element
is null.- ArgumentOutOfRangeException
If
atMostDistanceInPixels
is not a positive value.
RightOf(By)
Locates an element to the right of the specified element.
public RelativeBy RightOf(By locator)
Parameters
locator
ByThe locator describing the element to look to the right of for elements.
Returns
- RelativeBy
A RelativeBy object for use in finding the elements.
Exceptions
- ArgumentNullException
If
locator
is null.
RightOf(IWebElement)
Locates an element to the right of the specified element.
public RelativeBy RightOf(IWebElement element)
Parameters
element
IWebElementThe element to look to the right of for elements.
Returns
- RelativeBy
A RelativeBy object for use in finding the elements.
Exceptions
- ArgumentNullException
If
element
is null.
WithLocator(By)
Creates a new RelativeBy for finding elements with the specified tag name.
public static RelativeBy WithLocator(By by)
Parameters
by
ByA By object that will be used to find the initial element.
Returns
- RelativeBy
A RelativeBy object to be used in finding the elements.
Exceptions
- ArgumentNullException
If
by
is null.