Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 53 additions & 53 deletions src/WaitHelpers/ExpectedConditions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ public static Func<IWebDriver, bool> UrlMatches(string regex)
/// </summary>
/// <param name="locator">The locator used to find the element.</param>
/// <returns>The <see cref="IWebElement"/> once it is located.</returns>
public static Func<IWebDriver, IWebElement> ElementExists(By locator)
public static Func<ISearchContext, IWebElement> ElementExists(By locator)
{
return (driver) => { return driver.FindElement(locator); };
return (searchContext) => searchContext.FindElement(locator);
}

/// <summary>
Expand All @@ -116,19 +116,19 @@ public static Func<IWebDriver, IWebElement> ElementExists(By locator)
/// </summary>
/// <param name="locator">The locator used to find the element.</param>
/// <returns>The <see cref="IWebElement"/> once it is located and visible.</returns>
public static Func<IWebDriver, IWebElement> ElementIsVisible(By locator)
public static Func<ISearchContext, IWebElement> ElementIsVisible(By locator)
{
return (driver) =>
return (searchContext) =>
{
try
{
try
{
return ElementIfVisible(driver.FindElement(locator));
}
catch (StaleElementReferenceException)
{
return null;
}
};
return ElementIfVisible(searchContext.FindElement(locator));
}
catch (StaleElementReferenceException)
{
return null;
}
};
}

/// <summary>
Expand All @@ -138,13 +138,13 @@ public static Func<IWebDriver, IWebElement> ElementIsVisible(By locator)
/// </summary>
/// <param name="locator">The locator used to find the element.</param>
/// <returns>The list of <see cref="IWebElement"/> once it is located and visible.</returns>
public static Func<IWebDriver, ReadOnlyCollection<IWebElement>> VisibilityOfAllElementsLocatedBy(By locator)
public static Func<ISearchContext, ReadOnlyCollection<IWebElement>> VisibilityOfAllElementsLocatedBy(By locator)
{
return (driver) =>
return (searchContext) =>
{
try
{
var elements = driver.FindElements(locator);
var elements = searchContext.FindElements(locator);
if (elements.Any(element => !element.Displayed))
{
return null;
Expand All @@ -166,9 +166,9 @@ public static Func<IWebDriver, ReadOnlyCollection<IWebElement>> VisibilityOfAllE
/// </summary>
/// <param name="elements">list of WebElements</param>
/// <returns>The list of <see cref="IWebElement"/> once it is located and visible.</returns>
public static Func<IWebDriver, ReadOnlyCollection<IWebElement>> VisibilityOfAllElementsLocatedBy(ReadOnlyCollection<IWebElement> elements)
public static Func<ISearchContext, ReadOnlyCollection<IWebElement>> VisibilityOfAllElementsLocatedBy(ReadOnlyCollection<IWebElement> elements)
{
return (driver) =>
return (searchContext) =>
{
try
{
Expand All @@ -192,13 +192,13 @@ public static Func<IWebDriver, ReadOnlyCollection<IWebElement>> VisibilityOfAllE
/// </summary>
/// <param name="locator">The locator used to find the element.</param>
/// <returns>The list of <see cref="IWebElement"/> once it is located.</returns>
public static Func<IWebDriver, ReadOnlyCollection<IWebElement>> PresenceOfAllElementsLocatedBy(By locator)
public static Func<ISearchContext, ReadOnlyCollection<IWebElement>> PresenceOfAllElementsLocatedBy(By locator)
{
return (driver) =>
return (searchContext) =>
{
try
{
var elements = driver.FindElements(locator);
var elements = searchContext.FindElements(locator);
return elements.Any() ? elements : null;
}
catch (StaleElementReferenceException)
Expand All @@ -214,9 +214,9 @@ public static Func<IWebDriver, ReadOnlyCollection<IWebElement>> PresenceOfAllEle
/// <param name="element">The WebElement</param>
/// <param name="text">Text to be present in the element</param>
/// <returns><see langword="true"/> once the element contains the given text; otherwise, <see langword="false"/>.</returns>
public static Func<IWebDriver, bool> TextToBePresentInElement(IWebElement element, string text)
public static Func<ISearchContext, bool> TextToBePresentInElement(IWebElement element, string text)
{
return (driver) =>
return (searchContext) =>
{
try
{
Expand All @@ -236,13 +236,13 @@ public static Func<IWebDriver, bool> TextToBePresentInElement(IWebElement elemen
/// <param name="locator">The locator used to find the element.</param>
/// <param name="text">Text to be present in the element</param>
/// <returns><see langword="true"/> once the element contains the given text; otherwise, <see langword="false"/>.</returns>
public static Func<IWebDriver, bool> TextToBePresentInElementLocated(By locator, string text)
public static Func<ISearchContext, bool> TextToBePresentInElementLocated(By locator, string text)
{
return (driver) =>
return (searchContext) =>
{
try
{
var element = driver.FindElement(locator);
var element = searchContext.FindElement(locator);
var elementText = element.Text;
return elementText.Contains(text);
}
Expand All @@ -259,9 +259,9 @@ public static Func<IWebDriver, bool> TextToBePresentInElementLocated(By locator,
/// <param name="element">The WebElement</param>
/// <param name="text">Text to be present in the element</param>
/// <returns><see langword="true"/> once the element contains the given text; otherwise, <see langword="false"/>.</returns>
public static Func<IWebDriver, bool> TextToBePresentInElementValue(IWebElement element, string text)
public static Func<ISearchContext, bool> TextToBePresentInElementValue(IWebElement element, string text)
{
return (driver) =>
return (searchContext) =>
{
try
{
Expand All @@ -288,13 +288,13 @@ public static Func<IWebDriver, bool> TextToBePresentInElementValue(IWebElement e
/// <param name="locator">The locator used to find the element.</param>
/// <param name="text">Text to be present in the element</param>
/// <returns><see langword="true"/> once the element contains the given text; otherwise, <see langword="false"/>.</returns>
public static Func<IWebDriver, bool> TextToBePresentInElementValue(By locator, string text)
public static Func<ISearchContext, bool> TextToBePresentInElementValue(By locator, string text)
{
return (driver) =>
return (searchContext) =>
{
try
{
var element = driver.FindElement(locator);
var element = searchContext.FindElement(locator);
var elementValue = element.GetAttribute("value");
if (elementValue != null)
{
Expand Down Expand Up @@ -362,13 +362,13 @@ public static Func<IWebDriver, IWebDriver> FrameToBeAvailableAndSwitchToIt(By lo
/// </summary>
/// <param name="locator">The locator used to find the element.</param>
/// <returns><see langword="true"/> if the element is not displayed; otherwise, <see langword="false"/>.</returns>
public static Func<IWebDriver, bool> InvisibilityOfElementLocated(By locator)
public static Func<ISearchContext, bool> InvisibilityOfElementLocated(By locator)
{
return (driver) =>
return (searchContext) =>
{
try
{
var element = driver.FindElement(locator);
var element = searchContext.FindElement(locator);
return !element.Displayed;
}
catch (NoSuchElementException)
Expand All @@ -392,13 +392,13 @@ public static Func<IWebDriver, bool> InvisibilityOfElementLocated(By locator)
/// <param name="locator">The locator used to find the element.</param>
/// <param name="text">Text of the element</param>
/// <returns><see langword="true"/> if the element is not displayed; otherwise, <see langword="false"/>.</returns>
public static Func<IWebDriver, bool> InvisibilityOfElementWithText(By locator, string text)
public static Func<ISearchContext, bool> InvisibilityOfElementWithText(By locator, string text)
{
return (driver) =>
return (searchContext) =>
{
try
{
var element = driver.FindElement(locator);
var element = searchContext.FindElement(locator);
var elementText = element.Text;
if (string.IsNullOrEmpty(elementText))
{
Expand Down Expand Up @@ -428,11 +428,11 @@ public static Func<IWebDriver, bool> InvisibilityOfElementWithText(By locator, s
/// </summary>
/// <param name="locator">The locator used to find the element.</param>
/// <returns>The <see cref="IWebElement"/> once it is located and clickable (visible and enabled).</returns>
public static Func<IWebDriver, IWebElement> ElementToBeClickable(By locator)
public static Func<ISearchContext, IWebElement> ElementToBeClickable(By locator)
{
return (driver) =>
return (searchContext) =>
{
var element = ElementIfVisible(driver.FindElement(locator));
var element = ElementIfVisible(searchContext.FindElement(locator));
try
{
if (element != null && element.Enabled)
Expand All @@ -457,9 +457,9 @@ public static Func<IWebDriver, IWebElement> ElementToBeClickable(By locator)
/// </summary>
/// <param name="element">The element.</param>
/// <returns>The <see cref="IWebElement"/> once it is clickable (visible and enabled).</returns>
public static Func<IWebDriver, IWebElement> ElementToBeClickable(IWebElement element)
public static Func<ISearchContext, IWebElement> ElementToBeClickable(IWebElement element)
{
return (driver) =>
return (searchContext) =>
{
try
{
Expand All @@ -484,9 +484,9 @@ public static Func<IWebDriver, IWebElement> ElementToBeClickable(IWebElement ele
/// </summary>
/// <param name="element">The element.</param>
/// <returns><see langword="false"/> is the element is still attached to the DOM; otherwise, <see langword="true"/>.</returns>
public static Func<IWebDriver, bool> StalenessOf(IWebElement element)
public static Func<ISearchContext, bool> StalenessOf(IWebElement element)
{
return (driver) =>
return (searchContext) =>
{
try
{
Expand All @@ -505,7 +505,7 @@ public static Func<IWebDriver, bool> StalenessOf(IWebElement element)
/// </summary>
/// <param name="element">The element.</param>
/// <returns><see langword="true"/> given element is selected.; otherwise, <see langword="false"/>.</returns>
public static Func<IWebDriver, bool> ElementToBeSelected(IWebElement element)
public static Func<IWebElement, bool> ElementToBeSelected(IWebElement element)
{
return ElementSelectionStateToBe(element, true);
}
Expand All @@ -516,9 +516,9 @@ public static Func<IWebDriver, bool> ElementToBeSelected(IWebElement element)
/// <param name="element">The element.</param>
/// <param name="selected">selected or not selected</param>
/// <returns><see langword="true"/> given element is in correct state.; otherwise, <see langword="false"/>.</returns>
public static Func<IWebDriver, bool> ElementToBeSelected(IWebElement element, bool selected)
public static Func<ISearchContext, bool> ElementToBeSelected(IWebElement element, bool selected)
{
return (driver) =>
return (searchContext) =>
{
return element.Selected == selected;
};
Expand All @@ -530,9 +530,9 @@ public static Func<IWebDriver, bool> ElementToBeSelected(IWebElement element, bo
/// <param name="element">The element.</param>
/// <param name="selected">selected or not selected</param>
/// <returns><see langword="true"/> given element is in correct state.; otherwise, <see langword="false"/>.</returns>
public static Func<IWebDriver, bool> ElementSelectionStateToBe(IWebElement element, bool selected)
public static Func<IWebElement, bool> ElementSelectionStateToBe(IWebElement element, bool selected)
{
return (driver) =>
return (webElement) =>
{
return element.Selected == selected;
};
Expand All @@ -543,7 +543,7 @@ public static Func<IWebDriver, bool> ElementSelectionStateToBe(IWebElement eleme
/// </summary>
/// <param name="locator">The locator used to find the element.</param>
/// <returns><see langword="true"/> given element is selected.; otherwise, <see langword="false"/>.</returns>
public static Func<IWebDriver, bool> ElementToBeSelected(By locator)
public static Func<ISearchContext, bool> ElementToBeSelected(By locator)
{
return ElementSelectionStateToBe(locator, true);
}
Expand All @@ -554,13 +554,13 @@ public static Func<IWebDriver, bool> ElementToBeSelected(By locator)
/// <param name="locator">The locator used to find the element.</param>
/// <param name="selected">selected or not selected</param>
/// <returns><see langword="true"/> given element is in correct state.; otherwise, <see langword="false"/>.</returns>
public static Func<IWebDriver, bool> ElementSelectionStateToBe(By locator, bool selected)
public static Func<ISearchContext, bool> ElementSelectionStateToBe(By locator, bool selected)
{
return (driver) =>
return (searchContext) =>
{
try
{
var element = driver.FindElement(locator);
var element = searchContext.FindElement(locator);
return element.Selected == selected;
}
catch (StaleElementReferenceException)
Expand Down