-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from pmahend1/dev
Migrate cleanup from dev
- Loading branch information
Showing
5 changed files
with
224 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using OpenQA.Selenium; | ||
using OpenQA.Selenium.Support.UI; | ||
using System; | ||
|
||
namespace MSRewards | ||
{ | ||
public static class Extensions | ||
{ | ||
public static bool IsClickable(this IWebElement webElement) | ||
{ | ||
if (webElement != null) | ||
return webElement.Displayed && webElement.Enabled; | ||
else | ||
return false; | ||
} | ||
|
||
public static IWebElement FindClickableElement(this IWebDriver driver, By condition, int fromSeconds = 10) | ||
{ | ||
bool isElementPresent = false; | ||
IWebElement singleElement = null; | ||
|
||
var driverWait = new WebDriverWait(driver, TimeSpan.FromSeconds(fromSeconds)); | ||
driverWait.IgnoreExceptionTypes(typeof(NoSuchElementException)); | ||
|
||
try | ||
{ | ||
isElementPresent = driverWait.Until(d => d.FindElement(condition).IsClickable()); | ||
|
||
if (isElementPresent) | ||
{ | ||
singleElement = driver.FindElement(condition); | ||
} | ||
} | ||
catch | ||
{ | ||
// log any errors | ||
} | ||
|
||
return singleElement; | ||
} | ||
|
||
public static bool WaitUntilClickable(this IWebDriver driver, By condition, int fromSeconds = 10) | ||
{ | ||
var element = driver.FindClickableElement(condition, fromSeconds); | ||
return (element != null); | ||
} | ||
|
||
|
||
public static void WaitUntilElementFound(this IWebDriver driver, By condition, int fromSeconds = 10) | ||
{ | ||
WebDriverWait waiter = new WebDriverWait(driver, TimeSpan.FromSeconds(fromSeconds)); | ||
waiter.IgnoreExceptionTypes(typeof(NoSuchElementException)); | ||
waiter.Until(d => d.FindElement(condition) != null); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.