public static bool Assert(UI.UIAssertAction action, OpenQA.Selenium.IWebDriver webDriver) { By locator = SeleniumUIHelper.GetBy(action.Element); OpenQA.Selenium.IWebElement element = SeleniumUIHelper.GetElement(webDriver, locator); switch (action.AssertType) { case UIActionSeertType.Text: return(CheckTextAssert(element, action)); case UIActionSeertType.CssClass: return(CheckCssClassAssert(element, action)); case UIActionSeertType.Count: System.Collections.ObjectModel.ReadOnlyCollection <IWebElement> elements = SeleniumUIHelper.GetElements(webDriver, locator); return(CheckCountElementAssert(elements, action)); case UIActionSeertType.Browser: return(CheckBrowserAssert(webDriver, action)); case UIActionSeertType.Exist: default: return(CheckExistAssert(element, action)); } }
public void Assert(UI.UIAssertAction action) { try { action.Status = SeleniumUIHelper.Assert(action, this.Driver) ? TestResultType.Success : TestResultType.Fail; } catch (System.Exception) { action.Status = TestResultType.Fail; string fileName = string.Format("{0}_{1}_{2}.png", action.TestCaseAction.TestCase.TestCaseRef.Key, action.TestCaseAction.ActionRef.Action, System.DateTime.Now.ToString("yyyyMMddHHmmssms")); SeleniumScreenshotHelper.CreateScreenshot(this.Driver, this.TestRunner.Environment, fileName); action.Error = new ValidationException("Common.ElementCanNotFound", action.Element, fileName); } }
private static bool CheckTextAssert(IWebElement element, UI.UIAssertAction action) { return(element != null && element.Text.ToLower() == action.Value.ToLower()); }
private static bool CheckCssClassAssert(IWebElement element, UI.UIAssertAction action) { return(element != null && element.GetAttribute("class").ToLower() == action.Value.ToLower()); }
private static bool CheckCountElementAssert(System.Collections.ObjectModel.ReadOnlyCollection <IWebElement> elements, UI.UIAssertAction action) { int count = int.Parse(action.Value); return(elements != null && elements.Count == count); }
private static bool CheckExistAssert(IWebElement element, UI.UIAssertAction action) { return(element != null); }
private static bool CheckBrowserAssert(OpenQA.Selenium.IWebDriver webDriver, UI.UIAssertAction action) { return(webDriver.Url.ToLower() == action.Value.ToLower()); }