Exemplo n.º 1
0
 public static void PopulateCollectionByRow(IWebElement table)
 {
     //Iterate through the rows and columns of the table
     if (InitialAssertion.IfElementIsVisible(table) == true)
     {
         var columns  = table.FindElements(By.TagName("th"));
         var rows     = table.FindElements(By.TagName("tr"));
         int rowIndex = 0;
         foreach (var row in rows)
         {
             int colIndex = 0;
             var colData  = row.FindElements(By.TagName("td"));
             foreach (var colValue in colData)
             {
                 _TableDataCollection.Add(new TableDataCollection
                 {
                     RowNumber = rowIndex,
                     ColName   = columns[colIndex].Text,
                     ColValue  = colValue.Text
                 });
                 colIndex++;
             }
             rowIndex++;
         }
     }
     else
     {
         SeleniumReporting.WriteResults(false, "Table is not available to fetch and compare the given search text");
     }
 }
Exemplo n.º 2
0
 //To Get selected Text from a DropDownList
 public static string ExtendedGetTxtDDL(this IWebElement element)
 {
     if (InitialAssertion.IfElementIsVisible(element) == true)
     {
         return(new SelectElement(element).AllSelectedOptions.SingleOrDefault().Text);
     }
     else
     {
         return(String.Empty);
     }
 }
Exemplo n.º 3
0
        //************************************************************

        //**************Extended Library method*****************
        //To Get Text from a Text box
        public static string ExtendedGetTxt(this IWebElement element)
        {
            if (InitialAssertion.IfElementIsVisible(element) == true)
            {
                return(element.GetAttribute("value"));
                //SeleniumReporting.WriteResults(true, element.GetAttribute("value"));
                //return true;
            }
            else
            {
                return(String.Empty);
            }
        }
Exemplo n.º 4
0
        //To Compare value from a cell with the searchstring
        public static bool ExtendedCellTextCopare(this IWebElement element, string SearchString, int RowNumber, string ColumnName)
        {
            string UIValue = TableDataUtility.ReadCellData(RowNumber, ColumnName);

            if (InitialAssertion.IfElementIsVisible(element) == true && UIValue == SearchString)
            {
                //Console.WriteLine("Text available in the UI : " + ExtendedGetTxt(element));
                SeleniumReporting.WriteResults(true, "Compare Text : '" + SearchString + "' with '" + UIValue + "'");
                return(true);
            }
            else
            {
                SeleniumReporting.WriteResults(false, "Compare Text : '" + SearchString + "' with '" + UIValue + "'");
                return(false);
            }
        }