コード例 #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);
                }
            }
        }
コード例 #2
0
ファイル: TableRow.cs プロジェクト: londa101/Selenium-1
        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);
                }
            }
        }
コード例 #3
0
ファイル: TableHeader.cs プロジェクト: londa101/Selenium-1
        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);
                }
            }
        }
コード例 #4
0
ファイル: BasePage.cs プロジェクト: londa101/Selenium-1
 protected T InitElement <T>(IWebElement webElement) where T : PageElement, new()
 {
     return(PageElementFactory.InitElement <T>(WebDriver, webElement));
 }
コード例 #5
0
ファイル: BasePage.cs プロジェクト: londa101/Selenium-1
 protected T InitElement <T>(By by) where T : PageElement, new()
 {
     return(PageElementFactory.InitElement <T>(WebDriver, by));
 }