コード例 #1
0
 public static int GetRowCountInGrid()
 {
     return(BrowserServices.FindElements("CssSelector", DashboardPageObject.RowValueCssSelector).Count);
 }
コード例 #2
0
 public void Verify_Table_Sort()
 {
     try
     {
         CommonMethods.Login(CommonMethods.Config["username"], CommonMethods.Config["password"]);
         Assert.True(BrowserServices.IsElementPresent("CssSelector", DashboardPageObject.CompareExpenseCssSelector), "Compare Expense Link should be present after the login.");
         int                row                 = CommonMethods.GetRowCountInGrid();
         List <string>      oldstatusList       = new List <string>();
         List <string>      olddateList         = new List <string>();
         List <string>      olddescriptionList  = new List <string>();
         List <string>      oldcategoryList     = new List <string>();
         List <string>      oldamountList       = new List <string>();
         List <Transaction> oldTransactionsList = new List <Transaction>();
         List <string>      newstatusList       = new List <string>();
         List <string>      newdateList         = new List <string>();
         List <string>      newdescriptionList  = new List <string>();
         List <string>      newcategoryList     = new List <string>();
         List <string>      newamountList       = new List <string>();
         List <Transaction> newTransactionsList = new List <Transaction>();
         string             dateValue           = "";
         ////Extracting values from transaction grid
         for (int i = 1; i <= row; i++)
         {
             oldstatusList.Add(BrowserServices.GetElementText("CssSelector", Format(DashboardPageObject.StatusValueCssSelector, i)));
             olddescriptionList.Add(BrowserServices.GetElementText("CssSelector", Format(DashboardPageObject.DescriptionValueCssSelector, i)));
             oldcategoryList.Add(BrowserServices.GetElementText("CssSelector", Format(DashboardPageObject.CategoryValueCssSelector, i)));
             oldamountList.Add(BrowserServices.GetElementText("CssSelector", Format(DashboardPageObject.AmountValueCssSelector, i)));
             IList <IWebElement> dateList = BrowserServices.FindElements("CssSelector", Format(DashboardPageObject.DateValueCssSelector, i));
             foreach (IWebElement date in dateList)
             {
                 dateValue += date.Text;
             }
             olddateList.Add(dateValue);
             dateValue = "";
             Transaction oldTransaction = new Transaction(oldstatusList[i - 1], olddateList[i - 1], olddescriptionList[i - 1], oldcategoryList[i - 1], oldamountList[i - 1]);
             oldTransactionsList.Add(oldTransaction);
         }
         //Clicking the amount label fro sorting
         CommonMethods.ClickAmountLabel();
         //Extracting new values from transaction grid
         for (int i = 1; i <= row; i++)
         {
             newstatusList.Add(BrowserServices.GetElementText("CssSelector", Format(DashboardPageObject.StatusValueCssSelector, i)));
             newdescriptionList.Add(BrowserServices.GetElementText("CssSelector", Format(DashboardPageObject.DescriptionValueCssSelector, i)));
             newcategoryList.Add(BrowserServices.GetElementText("CssSelector", Format(DashboardPageObject.CategoryValueCssSelector, i)));
             newamountList.Add(BrowserServices.GetElementText("CssSelector", Format(DashboardPageObject.AmountValueCssSelector, i)));
             IList <IWebElement> dateList = BrowserServices.FindElements("CssSelector", Format(DashboardPageObject.DateValueCssSelector, i));
             foreach (IWebElement date in dateList)
             {
                 dateValue += date.Text;
             }
             newdateList.Add(dateValue);
             dateValue = "";
             //Checking whether the amount value is sorted.
             if (i > 1)
             {
                 var amountI  = newamountList[i - 2].Replace("USD", "").Replace(" ", "");
                 var amountII = newamountList[i - 1].Replace("USD", "").Replace(" ", "");
                 if (Convert.ToDecimal(amountI) < Convert.ToDecimal(amountII))
                 {
                     Console.Out.WriteLine("Amount is sorted.");
                 }
                 //Sorting is not working
                 else
                 {
                     Console.Out.WriteLine("Amount is not sorted in V2 app.");
                 }
             }
             Transaction newTransaction = new Transaction(newstatusList[i - 1], newdateList[i - 1], newdescriptionList[i - 1], newcategoryList[i - 1], newamountList[i - 1]);
             newTransactionsList.Add(newTransaction);
         }
         //Verifying the new transactionList to the old TransactionList
         foreach (Transaction transaction in newTransactionsList)
         {
             Assert.True(oldTransactionsList.Any(x => x.Status == transaction.Status && x.Amount == transaction.Amount && x.Description == transaction.Description && x.Date == transaction.Date && x.Category == transaction.Category), "Transactions data Should be intact even after clicking on amount.");
         }
     }
     catch (Exception e)
     {
         BrowserServices.ScreenShot("Table_Sort_Shot");
         Console.Out.WriteLine(e);
     }
 }