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
locatorByThe locator describing the element to look above for elements.
Returns
- RelativeBy
A RelativeBy object for use in finding the elements.
Exceptions
- ArgumentNullException
If
locatoris null.
Above(IWebElement)
Locates an element above the specified element.
public RelativeBy Above(IWebElement element)
Parameters
elementIWebElementThe element to look above for elements.
Returns
- RelativeBy
A RelativeBy object for use in finding the elements.
Exceptions
- ArgumentNullException
If
elementis null.
Below(By)
Locates an element below the specified element.
public RelativeBy Below(By locator)
Parameters
locatorByThe locator describing the element to look below for elements.
Returns
- RelativeBy
A RelativeBy object for use in finding the elements.
Exceptions
- ArgumentNullException
If
locatoris null.
Below(IWebElement)
Locates an element below the specified element.
public RelativeBy Below(IWebElement element)
Parameters
elementIWebElementThe element to look below for elements.
Returns
- RelativeBy
A RelativeBy object for use in finding the elements.
Exceptions
- ArgumentNullException
If
elementis null.
FindElement(ISearchContext)
Finds the first element matching the criteria.
public override IWebElement FindElement(ISearchContext context)
Parameters
contextISearchContextAn ISearchContext object to use to search for the elements.
Returns
- IWebElement
The first matching IWebElement on the current context.
Exceptions
- ArgumentException
If
contextis not IJavaScriptExecutor or wraps a driver that does.
FindElements(ISearchContext)
Finds all elements matching the criteria.
public override ReadOnlyCollection<IWebElement> FindElements(ISearchContext context)
Parameters
contextISearchContextAn 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
contextis 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
locatorByThe 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
locatoris null.
LeftOf(IWebElement)
Locates an element to the left of the specified element.
public RelativeBy LeftOf(IWebElement element)
Parameters
elementIWebElementThe element to look to the left of for elements.
Returns
- RelativeBy
A RelativeBy object for use in finding the elements.
Exceptions
- ArgumentNullException
If
elementis null.
Near(By)
Locates an element near the specified element.
public RelativeBy Near(By locator)
Parameters
locatorByThe locator describing the element to look near for elements.
Returns
- RelativeBy
A RelativeBy object for use in finding the elements.
Exceptions
- ArgumentNullException
If
locatoris null.
Near(By, int)
Locates an element near the specified element.
public RelativeBy Near(By locator, int atMostDistanceInPixels)
Parameters
locatorByThe locator describing the element to look near for elements.
atMostDistanceInPixelsintThe maximum distance from the element to be considered "near."
Returns
- RelativeBy
A RelativeBy object for use in finding the elements.
Exceptions
- ArgumentNullException
If
locatoris null.- ArgumentOutOfRangeException
If
atMostDistanceInPixelsis not a positive value.
Near(IWebElement)
Locates an element near the specified element.
public RelativeBy Near(IWebElement element)
Parameters
elementIWebElementThe element to look near for elements.
Returns
- RelativeBy
A RelativeBy object for use in finding the elements.
Exceptions
- ArgumentNullException
If
elementis null.
Near(IWebElement, int)
Locates an element near the specified element.
public RelativeBy Near(IWebElement element, int atMostDistanceInPixels)
Parameters
elementIWebElementThe element to look near for elements.
atMostDistanceInPixelsintThe maximum distance from the element to be considered "near."
Returns
- RelativeBy
A RelativeBy object for use in finding the elements.
Exceptions
- ArgumentNullException
If
elementis null.- ArgumentOutOfRangeException
If
atMostDistanceInPixelsis not a positive value.
RightOf(By)
Locates an element to the right of the specified element.
public RelativeBy RightOf(By locator)
Parameters
locatorByThe 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
locatoris null.
RightOf(IWebElement)
Locates an element to the right of the specified element.
public RelativeBy RightOf(IWebElement element)
Parameters
elementIWebElementThe element to look to the right of for elements.
Returns
- RelativeBy
A RelativeBy object for use in finding the elements.
Exceptions
- ArgumentNullException
If
elementis null.
WithLocator(By)
Creates a new RelativeBy for finding elements with the specified tag name.
public static RelativeBy WithLocator(By by)
Parameters
byByA 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
byis null.