/// <summary> /// Click Action Wrapper Method /// </summary> /// <param name="element">IWebElement Object</param> /// <param name="report">TestReporting Object</param> /// <param name="elementName">Web Element Name</param> public static void Click(this IWebElement element, TestReporting report, string elementName) { if (element.Displayed && element.Enabled) { element.Click(); report.SetStepStatusPass($"Clicked on the element [{elementName}]."); } else { report.SetStepStatusError($"Element [{elementName}] is not displayed"); throw new Exception($"Element [{elementName}] is not displayed"); } }
/// <summary> /// Launch - GoToUrl Wrapper Method /// </summary> /// <param name="driver">IWebDriver Object</param> /// <param name="report">TestReporting Object</param> /// <param name="url">Web URL String</param> public static void LaunchUrl(this IWebDriver driver, TestReporting report, string url) { try { driver.Navigate().GoToUrl(url); report.SetStepStatusPass($"URL [{url}] launched successfully."); } catch (Exception e) { report.SetStepStatusError(e.Message); throw new Exception(e.Message); } }
/// <summary> /// SendKeys Action Wrapper Method /// </summary> /// <param name="element">IWebElement Object</param> /// <param name="report">TestReporting Object</param> /// <param name="value">Ttext Input Value String</param> /// <param name="elementName">Web Element Name</param> public static void SendKeys(this IWebElement element, TestReporting report, string value, string elementName) { try { element.SendKeys(value); report.SetStepStatusPass($"SendKeys value [{value}] to element [{elementName}]."); } catch (Exception e) { report.SetStepStatusError(e.Message); throw new Exception(e.Message); } }
/// <summary> /// Clear Action Wrapper Method /// </summary> /// <param name="element">IWebElement Object</param> /// <param name="report">TestReporting Object</param> /// <param name="elementName">Web Element Name</param> public static void Clear(this IWebElement element, TestReporting report, string elementName) { element.Clear(); if (element.Text.Equals(string.Empty)) { report.SetStepStatusPass($"Cleared element [{elementName}] content."); } else { report.SetStepStatusError($"Element [{elementName}] content is not cleared. Element value is [{element.Text}]"); throw new Exception($"Element [{elementName}] content is not cleared."); } }