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 Click(UI.UIClickAction action) { try { action.Status = TestResultType.Fail; OpenQA.Selenium.IWebElement element = SeleniumUIHelper.GetElement(this.Driver, SeleniumUIHelper.GetBy(action.Element)); element.Click(); action.Status = TestResultType.Success; } 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); } }