Beispiel #1
0
        private string[] GetRelatedListRowData(IWebElement row, DataRowTypeLoad rowTypeLoad)
        {
            if (row == null)
            {
                return new string[] { }
            }
            ;

            var data = row.FindElements(By.XPath(RelatedListBodyTableRowDataPart));

            if (data != null)
            {
                return(data.Select(x =>
                {
                    if (rowTypeLoad == DataRowTypeLoad.ElementText)
                    {
                        return x.IsSelectable() ? x.GetSelectedOptionText() : x.Text;
                    }

                    if (rowTypeLoad == DataRowTypeLoad.InnerHtml)
                    {
                        return x.GetAttribute("innerHTML");
                    }

                    //if (rowTypeLoad == DataRowTypeLoad.HtmlInnerText)
                    //    return x.GetAttribute("innerHTML").AsHtmlDocument().DocumentNode.InnerText;

                    return string.Empty;
                }).ToArray());
            }
            else
            {
                return(new string[] { });
            }
        }
Beispiel #2
0
        public virtual DataSet GetRelatedLists(DataRowTypeLoad rowTypeLoad = DataRowTypeLoad.ElementText)
        {
            if (_DSrelatedTables != null)
            {
                return(_DSrelatedTables);
            }

            _DSrelatedTables = new DataSet();

            var relatedListTableElements = PageBase.WebDriver.FindElements(RelatedListBodyTables);
            var relatedListTitles        = PageBase.WebDriver.FindElements(RelatedListHeaderTitles);

            if (relatedListTableElements != null && relatedListTableElements.Any())
            {
                var index = 0;

                relatedListTableElements.ToList().ForEach(table =>
                {
                    DataTable dt = CreateRelatedListDataTable(table, relatedListTitles[index].Text.Replace(" ", string.Empty), rowTypeLoad);
                    if (dt != null)
                    {
                        _DSrelatedTables.Tables.Add(dt);
                    }
                    index++;
                });
            }

            return(_DSrelatedTables);
        }
Beispiel #3
0
        /// <summary>
        /// Virtual method to load all detail tables section from the page object.
        /// You can override this method if any special operation to load the tables is needed.
        /// </summary>
        /// <param name="rowTypeLoad">Determines how the rows will be loaded. Default is the WebElement's text.</param>
        /// <returns>A <see cref="DataSet"/> with all tables found on the page object.</returns>
        public virtual DataSet GetDetailTables(DataRowTypeLoad rowTypeLoad = DataRowTypeLoad.ElementText)
        {
            if (_DSdetailTables != null)
            {
                return(_DSdetailTables);
            }

            _DSdetailTables = new DataSet();

            if (DetailTables != null && DetailTables.Any())
            {
                var index      = 0;
                var tableNames = GetTableNames(DetailTables.Count);

                DetailTables.ToList().ForEach(table =>
                {
                    DataTable dt = CreateDataTable(table, tableNames[index], rowTypeLoad);
                    if (dt != null)
                    {
                        _DSdetailTables.Tables.Add(dt);
                    }
                    index++;
                });
            }

            return(_DSdetailTables);
        }
Beispiel #4
0
        /// <summary>
        /// Creates a <see cref="DataTable"/> object from a table element. The table's name will follow the index parameter.
        /// </summary>
        private DataTable CreateDataTable(IWebElement table, string tableName, DataRowTypeLoad rowTypeLoad)
        {
            var newDataTable = new DataTable(tableName);

            var rows    = GetRows(table);
            var columns = GetColumns(rows);

            if (columns != null)
            {
                columns.ToList().ForEach(col => newDataTable.Columns.Add(col, typeof(string)));
            }

            if (columns == null || !columns.Any())
            {
                return(null);
            }

            if (rows != null)
            {
                newDataTable.BeginLoadData();
                rows.ToList().ForEach(row =>
                {
                    var newRow    = newDataTable.NewRow();
                    var itemArray = GetRowData(row, rowTypeLoad);

                    if (itemArray.Length > columns.Count())
                    {
                        newRow.ItemArray = itemArray.Take(columns.Count()).ToArray();
                    }
                    else
                    {
                        newRow.ItemArray = itemArray;
                    }

                    newDataTable.Rows.Add(newRow);
                });
                newDataTable.EndLoadData();
            }

            return(newDataTable);
        }