/// <summary>
 /// Returns true if at least one IWebElement on the current page matches the provided identifier
 /// </summary>
 /// <param name="identifier">identifier describing the element(s) to find</param>
 /// <returns>True if at least one element matches identifier, otherwise false</returns>
 #pragma warning disable S1481 // Assigning to unused variable necessary to carry out intended function ot method
 public bool ElementExists(By identifier, string name = "Element")
 {
     _logger.Write($"VERIFY: {name} exists");
     try
     {
         IWebElement foundElements = _driver.FindElement(identifier);
         _logger.Write($"{name} is present");
         return(true);
     }
     catch (NoSuchElementException)
     {
         _logger.Write($"No {name} found");
         return(false);
     }
 }
Beispiel #2
0
 /// <summary>
 /// Find all IWebElements matching the specified identifier and return as Element object
 /// </summary>
 /// <param name="identifier">Identifier describing the element(s) to find</param>
 /// <param name="elementName">Name of IWebElement(s) for logging purposes</param>
 /// <returns>Element containing all IWebElements on current page matching identifier</returns>
 public Element Elements(By identifier, string elementName)
 {
     _logger.Write($"FIND: Element(s) {elementName}");
     try
     {
         List <IWebElement> elements = new List <IWebElement>(_driver.FindElements(identifier));
         _logger.Write($"{elements.Count} matching Element(s) found");
         return(new Element(elements, elementName));
     }
     catch (NoSuchElementException)
     {
         _logger.Write("0 matching Element(s) found", Level.Warn);
         return(null);
     }
 }
Beispiel #3
0
 public void Pass()
 {
     _hasPassed = true;
     _logger.Write("PASS");
 }
Beispiel #4
0
        /// <summary>
        /// Click the specified IWebElement
        /// </summary>
        /// <param name="element">Target IWebelement</param>
        /// <param name="name">Name of element (For logging purposes)</param>
        public void Click(IWebElement element, string name)
        {
            _logger.Write($"INTERACT: Click Element {name}");
            try
            {
                element.Click();
                _logger.Write($"Action Completed");
            }
            catch (Exception e) when(e is InvalidElementStateException || e is ElementNotVisibleException ||
                                     e is StaleElementReferenceException || e is NoSuchElementException || e is NullReferenceException)
            {
                string exception = e.GetType().ToString();

                _logger.Write($"Element {name} could not be clicked: {exception}", Level.Error);
            }
        }
 /// <summary>
 /// Instruct the webdriver to go to a specific URL
 /// </summary>
 /// <param name="url">URL to navigate to</param>
 public void GoToUrl(string url)
 {
     _logger.Write($"NAVIGATE: Go to URL: '{url}'");
     _driver.Navigate().GoToUrl(url);
     _logger.Write("Navigation Successful");
 }