Ejemplo n.º 1
0
        public string PageOfPagesLogic(PagingData pagesQuantity)
        {
            IWebElement pagesaQua = PropertiesCollection.driver.FindElement(By.CssSelector(pagesQuantity.pagesQua));
            string      textPages = pagesaQua.Text;

            return(textPages);
        }
Ejemplo n.º 2
0
 public int SelectPerPage(PagingData pagingData, IWebElement dropdownSelectPerPage)
 {
     int[] recOnPageArray = { 20, 50, 100, 250 };
     if (recOnPageArray[0] > ItemsFound(pagingData))
     {
         PropertiesCollection._reportingTasks.Log(Status.Info, "ITEMS FOUND LESS : " + ItemsFound(pagingData));
         return(0);
     }
     else
     {
         int i = 1;
         for (; i < recOnPageArray.Length; i++)
         {
             if (recOnPageArray[i] >= ItemsFound(pagingData))
             {
                 PropertiesCollection._reportingTasks.Log(Status.Info, "ITEMS FOUND OK : " + ItemsFound(pagingData));
                 break;
             }
         }
         var selectElement = new SelectElement(dropdownSelectPerPage);
         SeleniumGetMethod.WaitForPageLoad(PropertiesCollection.driver);
         selectElement.SelectByIndex(i - 1);
         //selectElement.SelectByIndex(0);
         var valueSelected = selectElement.SelectedOption.Text;
         SeleniumGetMethod.WaitForPageLoad(PropertiesCollection.driver);
         PropertiesCollection._reportingTasks.Log(Status.Info, "Selected value...: " + valueSelected);
         Console.WriteLine("Selected value is " + valueSelected);
         return(Int32.Parse(valueSelected));
     }
 }
Ejemplo n.º 3
0
        public int ItemsFound(PagingData pagingData)
        {
            //int result = JavaScriptInvoker.ReadHttpResponseJSon(url);
            IWebElement itemsOnthePage     = PropertiesCollection.driver.FindElement(By.CssSelector(pagingData.recordsFound));
            string      itemsOnthePageText = itemsOnthePage.Text;

            string[] several = itemsOnthePageText.Split(' ');
            int      value   = Int32.Parse(several[0]);

            PropertiesCollection._reportingTasks.Log(Status.Info, "pages text : " + itemsOnthePageText);
            PropertiesCollection._reportingTasks.Log(Status.Info, "There are pages we have : " + value);
            Console.WriteLine(value);
            return(value);
        }
Ejemplo n.º 4
0
        public int GetPagesQuantity(PagingData pagesQuantity)
        {
            SeleniumGetMethod.WaitForPageLoad(PropertiesCollection.driver);
            IWebElement pagesaQua = PropertiesCollection.driver.FindElement(By.CssSelector(pagesQuantity.pagesQua));
            string      textPages = pagesaQua.Text;

            string[] several = textPages.Split('f');
            int      value   = 0;

            try
            {
                value = Int32.Parse(several[1]);
            }
            catch (Exception msg)
            {
                PropertiesCollection._reportingTasks.Log(Status.Info, "I can't convert this string to integer..<br>" + msg.ToString());
            }
            PropertiesCollection._reportingTasks.Log(Status.Info, "pages text : " + textPages);
            PropertiesCollection._reportingTasks.Log(Status.Info, "There are pages we have : " + value);
            Console.WriteLine("Pages quantity is " + value);
            return(value);
        }
Ejemplo n.º 5
0
        public void CheckPaging(PagingData data)
        {
            IWebElement recordsFound          = PropertiesCollection.driver.FindElement(By.CssSelector(data.recordsFound));
            IWebElement dropdownSelectPerPage = PropertiesCollection.driver.FindElement(By.CssSelector(data.dropdownSelectPerPage));
            IWebElement pagesaQua             = PropertiesCollection.driver.FindElement(By.CssSelector(data.pagesQua));
            //check logic
            int selectedValue = SelectPerPage(data, dropdownSelectPerPage);

            SeleniumGetMethod.WaitForPageLoad(PropertiesCollection.driver);
            Thread.Sleep(2000);
            IList <IWebElement> tableRecors = PropertiesCollection.driver.FindElements(By.CssSelector(data.tableRecors));
            int records = GetTableRecords(tableRecors);

            PropertiesCollection._reportingTasks.Log(Status.Info, "Selected per page value : " + selectedValue + "<br>" + "There are records in the grid...: " + records);
            try
            {
                Assert.IsTrue(selectedValue == records, "Paging doesn't work properly!!!");
            }
            catch (Exception message)
            {
                PropertiesCollection._reportingTasks.Log(Status.Info, "paging works wrong, try catch works" + "<br>" + message.ToString());
            }

            int numberPages = GetPagesQuantity(data);

            /*string quatLabel = PageOfPagesLogic(data).ToString();
             * Assert.IsTrue(quatLabel == $"1 of {numberPages}", "Paging doesn't work properly - smth wrong with label...");
             * PropertiesCollection._reportingTasks.Log(Status.Info, "LABEL VALUE : " + quatLabel);*/
            if (numberPages == 0)
            {
                PropertiesCollection._reportingTasks.Log(Status.Warning, "Number of pages returns 0 so it's impossible to test paging here...");
                return;
            }
            if (numberPages == 1)
            {
                PropertiesCollection._reportingTasks.Log(Status.Info, "There is only 1 page...");
            }

            if (1 < numberPages && numberPages <= 3)
            {
                for (int i = 1; i < numberPages; i++)
                {
                    IWebElement nextPge = PropertiesCollection.driver.FindElement(By.CssSelector(data.nextPage));
                    SeleniumGetMethod.WaitForElement(PropertiesCollection.driver, nextPge);
                    nextPge.Click();
                    SeleniumGetMethod.WaitForPageLoad(PropertiesCollection.driver);
                    Thread.Sleep(2000);
                }

                /* quatLabel = PageOfPagesLogic(data).ToString();
                 * PropertiesCollection._reportingTasks.Log(Status.Info, "label LOOP value : " + quatLabel);
                 * Assert.IsTrue(quatLabel == $"{numberPages} of {numberPages}", "Paging doesn't work properly - smth wrong with label...loop..");*/
                for (int count = numberPages; count > 1; count--)
                {
                    IWebElement prevPage = PropertiesCollection.driver.FindElement(By.CssSelector(data.prevPage));
                    SeleniumGetMethod.WaitForElement(PropertiesCollection.driver, prevPage);
                    prevPage.Click();
                    SeleniumGetMethod.WaitForPageLoad(PropertiesCollection.driver);
                    Thread.Sleep(2000);
                }

                /*quatLabel = PageOfPagesLogic(data).ToString();
                 * Assert.IsTrue(quatLabel == $"{1} of {numberPages}", "Paging doesn't work properly - smth wrong with label...loop..");
                 * PropertiesCollection._reportingTasks.Log(Status.Info, "label LOOP value : " + quatLabel);*/
            }
            //if (numberPages >= 3)
            if (numberPages > 3)
            {
                numberPages = 4;
                for (int i = 1; i < numberPages; i++)
                {
                    IWebElement nextPge = PropertiesCollection.driver.FindElement(By.CssSelector(data.nextPage));
                    nextPge.Click();
                    SeleniumGetMethod.WaitForPageLoad(PropertiesCollection.driver);
                    Thread.Sleep(2000);
                }
                for (numberPages = 4; numberPages > 1; numberPages--)
                {
                    IWebElement prevPage = PropertiesCollection.driver.FindElement(By.CssSelector(data.prevPage));
                    SeleniumGetMethod.WaitForElement(PropertiesCollection.driver, prevPage);
                    prevPage.Click();
                    SeleniumGetMethod.WaitForPageLoad(PropertiesCollection.driver);
                    Thread.Sleep(2000);
                }
            }
            IWebElement lastPage = PropertiesCollection.driver.FindElement(By.CssSelector(data.lastPage));

            SeleniumGetMethod.WaitForElement(PropertiesCollection.driver, lastPage);
            lastPage.Click();
            Thread.Sleep(2000);

            /*quatLabel = PageOfPagesLogic(data).ToString();
             * Assert.IsTrue(quatLabel == $"{numberPages} of {numberPages}", "Paging doesn't work properly - smth wrong with label...");*/
            IWebElement firstPage = PropertiesCollection.driver.FindElement(By.CssSelector(data.firstPage));

            SeleniumGetMethod.WaitForElement(PropertiesCollection.driver, firstPage);
            firstPage.Click();

            /*quatLabel = PageOfPagesLogic(data).ToString();
             * Assert.IsTrue(quatLabel == $"1 of {numberPages}", "Paging doesn't work properly - smth wrong with label...");*/
            SeleniumGetMethod.WaitForPageLoad(PropertiesCollection.driver);
        }