Ejemplo n.º 1
0
        public string PageOfPagesLogic(PagingData pagesQuantity)
        {
            SwitchToFrameHelper.ToDefaultContext(PropertiesCollection.driver);
            SwitchToFrameHelper.ToMainBody(PropertiesCollection.driver);
            SwitchToFrameHelper.ToMainFrame(PropertiesCollection.driver);

            IWebElement pagesaQua = PropertiesCollection.driver.FindElement(By.CssSelector(pagesQuantity.pagesQua));
            string      textPages = pagesaQua.Text;

            //PropertiesCollection._reportingTasks.Log(Status.Info, "pages text : " + textPages);
            return(textPages);
        }
Ejemplo n.º 2
0
        public int GetPagesQuantity(PagingData pagesQuantity)
        {
            SwitchToFrameHelper.ToDefaultContext(PropertiesCollection.driver);
            SwitchToFrameHelper.ToMainBody(PropertiesCollection.driver);
            SwitchToFrameHelper.ToMainFrame(PropertiesCollection.driver);

            IWebElement pagesaQua = PropertiesCollection.driver.FindElement(By.CssSelector(pagesQuantity.pagesQua));
            string      textPages = pagesaQua.Text;

            string[] several = textPages.Split(' ');
            int      value   = Int32.Parse(several[2]);

            PropertiesCollection._reportingTasks.Log(Status.Info, "pages text : " + textPages);
            PropertiesCollection._reportingTasks.Log(Status.Info, "There are pages we have : " + value);
            return(value);
        }
Ejemplo n.º 3
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 goButton  = PropertiesCollection.driver.FindElement(By.Id(data.goButton));
            IWebElement pagesaQua = PropertiesCollection.driver.FindElement(By.CssSelector(data.pagesQua));
            //check logic
            int selectedValue = SelectPerPage(recordsFound, dropdownSelectPerPage, goButton);

            SeleniumGetMethod.WaitForPageLoad(PropertiesCollection.driver);
            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);
            Assert.IsTrue(selectedValue == records, "Paging doesn't work properly!!!");
            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 == 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.Id(data.nextPage));
                    nextPge.Click();
                    SeleniumGetMethod.WaitForPageLoad(PropertiesCollection.driver);
                }
                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.Id(data.prevPage));
                    prevPage.Click();
                    SeleniumGetMethod.WaitForPageLoad(PropertiesCollection.driver);
                }
                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)
            {
                numberPages = 4;
                for (int i = 1; i < numberPages; i++)
                {
                    IWebElement nextPge = PropertiesCollection.driver.FindElement(By.Id(data.nextPage));
                    nextPge.Click();
                    SeleniumGetMethod.WaitForPageLoad(PropertiesCollection.driver);
                }
                for (numberPages = 4; numberPages > 1; numberPages--)
                {
                    IWebElement prevPage = PropertiesCollection.driver.FindElement(By.Id(data.prevPage));
                    prevPage.Click();
                    SeleniumGetMethod.WaitForPageLoad(PropertiesCollection.driver);
                }
            }
            IWebElement lastPage = PropertiesCollection.driver.FindElement(By.Id(data.lastPage));

            lastPage.Click();
            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.Id(data.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);
            if (data.setGotoPage != null)
            {
                PropertiesCollection._reportingTasks.Log(Status.Info, "There is 'GO TO PAGE' functionality, setGotoPage CssSelector is : " + data.setGotoPage);
                IWebElement setGotoPage = PropertiesCollection.driver.FindElement(By.CssSelector(data.setGotoPage));
                setGotoPage.SendKeys(numberPages.ToString());
                IWebElement goToSkipPage = PropertiesCollection.driver.FindElement(By.CssSelector(data.goToSkipPage));
                goToSkipPage.Click();
                quatLabel = PageOfPagesLogic(data).ToString();
                Assert.IsTrue(quatLabel == $"{numberPages} of {numberPages}", "Paging doesn't work properly - smth wrong with label...loop..");
            }
            else
            {
                PropertiesCollection._reportingTasks.Log(Status.Info, " 'GO TO PAGE' doesn't exist...setGotoPage CssSelector is Null : " + data.setGotoPage);
            }
            SeleniumGetMethod.WaitForPageLoad(PropertiesCollection.driver);
        }