Beispiel #1
0
        public T this[int number]
        {
            get
            {
                number = number + 1;
                if (_tableRowCache.ContainsKey(number))
                {
                    return(_tableRowCache[number]);
                }

                if (number >= 1 && number <= NumRows)
                {
                    string      xpath      = "./tbody[" + this.BodyIndex + "]/tr[" + number + "]";
                    IWebElement webelement = WebElement.FindElement(By.XPath(xpath));

                    T tableRow = PageElementFactory.InitElement <T>(WebDriver, webelement);
                    tableRow.TableHeader = TableHeader;

                    _tableRowCache.Add(number, tableRow);

                    return(tableRow);
                }
                else
                {
                    throw new IndexOutOfRangeException("Tried to access invalid row number: " + number);
                }
            }
        }
        public string VerifySelectedValue()
        {
            var dropdown      = WebElement.FindElement(_driver, Dropdown, 10);
            var selectElement = new SelectElement(dropdown);

            return(selectElement.SelectedOption.GetAttribute("value").ToString());
        }
        public void ChooseOptions(string value)
        {
            var dropdown      = WebElement.FindElement(_driver, Dropdown, 10);
            var selectElement = new SelectElement(dropdown);

            selectElement.SelectByValue(value);
        }
Beispiel #4
0
        public void SelectItemByPartialText(string partialTextItemToSelect)
        {
            WebElement.FindElement(By.XPath($"./option[starts-with(text(), '{partialTextItemToSelect}')]")).Click();
            string message = $"The (Dropdown) [ {ControlName} ] selected the Item: [ {partialTextItemToSelect} ] using partial text";

            LoggerManagerClass.Instance.Information(message);
            TestCaseProvider.Instance.AddStepInCurrentTestCase(LogStepStatus.Passed, message);
        }
Beispiel #5
0
        public void FindElement()
        {
            var htmlNode = new HtmlNodeBuilder("<html><body><div id=\"page-body\">Hello world</div></body></html>").Build();

            var document = new WebElement(htmlNode, null);
            var div = document.FindElement(By.Id("page-body"));

            Assert.That(div.TagName, Is.EqualTo("div"));
            Assert.That(div.Text, Is.EqualTo("Hello world"));
        }
Beispiel #6
0
 public string  HasLeadingSign()
 {
     try
     {
         WaitForDisplayed(Timeouts.Default);
         string sign = WebElement.FindElement(By.XPath($"{InputGroupElement}//span[@class='input-group-addon']")).Text;
         return(sign);
     }
     catch (NoSuchElementException)
     {
         return(string.Empty);
     }
 }
Beispiel #7
0
 public string HasFollowingSign()
 {
     try
     {
         WaitForDisplayed(Timeouts.Default);
         string sign = WebElement.FindElement(By.XPath("./following-sibling::span[@class='input-group-addon']")).Text;
         return(sign);
     }
     catch (NoSuchElementException)
     {
         return(string.Empty);
     }
 }
Beispiel #8
0
        public PageElement this[int number]
        {
            get
            {
                number = number + 1; // HTML tables are 1-index
                if (number >= 1 && number <= NumColumns)
                {
                    string      xpath          = "./td[" + number + "]";
                    IWebElement cellWebElement = WebElement.FindElement(By.XPath(xpath));
                    PageElement pageElement    = null;

                    // we will try to initialize the contents of the table cell, depending on the tag name of the contents
                    try
                    {
                        WebDriver.EnableWait(false);
                        IWebElement childElement = null;
                        if ((childElement = FindDescendantByType(cellWebElement, "select")) != null)
                        {
                            pageElement = PageElementFactory.InitElement <DropDownList>(WebDriver, childElement);
                        }
                        else if ((childElement = FindDescendantByType(cellWebElement, "input")) != null)
                        {
                            pageElement = PageElementFactory.InitElement <TextField>(WebDriver, childElement);
                        }
                        else
                        {
                            pageElement = PageElementFactory.InitElement <Label>(WebDriver, cellWebElement);
                        }
                    }
                    catch (Exception)
                    {
                    }
                    finally
                    {
                        WebDriver.EnableWait(true);
                    }

                    return(pageElement);
                }
                else
                {
                    throw new IndexOutOfRangeException("Tried to access invalid index number: " + number);
                }
            }
        }
Beispiel #9
0
        public PageElement this[int number]
        {
            get
            {
                number = number + 1;
                if (number >= 1 && number <= NumColumns)
                {
                    string      xpath          = "./tr/th[" + number + "]";
                    IWebElement cellWebElement = WebElement.FindElement(By.XPath(xpath));
                    PageElement pageElement    = PageElementFactory.InitElement <PageElement>(WebDriver, cellWebElement);

                    return(pageElement);
                }
                else
                {
                    throw new IndexOutOfRangeException("Tried to access invalid index number: " + number);
                }
            }
        }
Beispiel #10
0
 public string GetInputLabel()
 {
     WaitForDisplayed(Timeouts.Default);
     return(WebElement.FindElement(By.XPath($"{InputGroupElement}/preceding-sibling::label/span/span")).Text);
 }
 public ElementSe FindElementSe(By by)
 {
     return(new ElementSe(WebElement.FindElement(by)));
 }
 public IWebElement FindElement(By by)
 {
     return(WebElement.FindElement(by));
 }
Beispiel #13
0
 public string GetValidationMessage()
 {
     WaitForDisplayed(Timeouts.Default);
     return(WebElement.FindElement(By.XPath($"{InputGroupElement}/following-sibling::div[contains(@id, 'helpblock')]//span[contains(@class,'input-helptext-error')]")).Text);
 }
 public Element <WebLocator> GetChild(WebLocator locator)
 {
     return(new SeleniumElement(WebElement.FindElement(locator.By), WebDriver));
 }
 public UITestControl GetParent()
 {
     return(new UITestControl(this.TopParent, WebElement.FindElement(By.XPath(".."))));
 }
Beispiel #16
0
 public void ClickOnDropdown()
 {
     WebElement.FindElement(_driver, Dropdown, 10).Click();
 }
Beispiel #17
0
 public bool VerifyContributeGraph()
 {
     return(WebElement.FindElement(_driver, ContributeGraph, 10).Displayed);
 }
Beispiel #18
0
 public void ClickDecrease()
 {
     WebElement.FindElement(By.XPath(".//ancestor::div[@class='input-group']//div[@class='input-group-btn']//button[@aria-label='decrease value']"))
     .Click();
 }
Beispiel #19
0
 public bool VerifDropdown()
 {
     return(WebElement.FindElement(_driver, Dropdown, 10).Displayed);
 }
Beispiel #20
0
 public void ClickSubmit()
 {
     WebElement.FindElement(_driver, SubmitButton, 5).Click();
 }
Beispiel #21
0
 /// <summary>
 /// Returns the text of cell by its selector.
 /// </summary>
 /// <param name="selector">Element selector.</param>
 /// <returns>Text of cell.</returns>
 public string GetCellBySelector(By selector)
 {
     return(WebElement.FindElement(selector).Text);
 }
Beispiel #22
0
 /// <summary>
 /// Returns cell by its content.
 /// </summary>
 /// <param name="content">Cell content.</param>
 /// <returns>IWebElement that represents searched cell.</returns>
 public IWebElement GetCellByContent(string content)
 {
     return(WebElement.FindElement(By.XPath($"//td[contains(.,'{content}')]")));
 }
Beispiel #23
0
 public void Child(By locator) => WebElement.FindElement(locator);
Beispiel #24
0
        ////// Implements the SearchContext interface.  //////

        public virtual IWebElement FindElement(By by)
        {
            return(WebElement.FindElement(by));
        }
Beispiel #25
0
 public void InputEmail(string email)
 {
     WebElement.FindElement(_driver, EmailInput, 5).SendKeys(email);
 }
Beispiel #26
0
 public bool VerifyProfile()
 {
     return(WebElement.FindElement(_driver, Profile, 10).Displayed);
 }
Beispiel #27
0
 public string GetSuccessText()
 {
     return(WebElement.FindElement(_driver, Content, 5).Text);
 }
Beispiel #28
0
 /// <summary>
 /// Find an element by the requested locator strategy.
 /// </summary>
 /// <param name="by">Locator strategy to use to find a requested element.</param>
 /// <returns></returns>
 internal Element FindElement(By by) => new Element(WebElement.FindElement(by), LogManager);