/// <summary> /// Check if element is present on page or not /// </summary> /// <param name="how"></param> /// <param name="elementName"></param> /// <returns></returns> public bool IsElementPresent(DriverUtilities.ElementAccessorType how, string elementName) { try { _driverUtils.IsElementPresent(how, elementName); return(true); } catch (NoSuchElementException) { Console.WriteLine("Element: {0} does not exist.", elementName); return(false); } }
/// <summary> /// Get the displayed text /// </summary> /// <param name="how"></param> /// <param name="elementName"></param> /// <returns>String</returns> public string GetText(DriverUtilities.ElementAccessorType how, string elementName) { try { string text = _driverUtils.GetText(how, elementName); return(text == null ? string.Empty : text); // return empty string instead of null } catch (Exception e) { _resultString.Append(e.Message); return(_resultString.ToString()); } }
/// <summary> /// Click on an element. /// </summary> /// <param name="how"></param> /// <param name="elementName"></param> public string Click(DriverUtilities.ElementAccessorType how, string elementName) { _resultString.Clear(); try { _driverUtils.Click(how, elementName); } catch (Exception e) { _resultString.Append(e.Message); } return(_resultString.ToString()); }
/// <summary> /// Sets an explicit wait time in seconds. /// </summary> /// <param name="driver"></param> /// <param name="seconds"></param> /// <param name="elementName"></param> public string ExplicitWait(DriverUtilities.ElementAccessorType how, string elementName, double seconds) { _resultString.Clear(); try { _driverUtils.ExplicitWait(how, elementName, seconds); } catch (Exception e) { _resultString.Append(e.Message); } return(_resultString.ToString()); }