示例#1
0
        public static void ClickLinks(IWebDriver driver, IWebElement table)
        {
            var    Rows = table.FindElements(By.TagName("tr"));
            string href = "";

            foreach (IWebElement item in Rows[0].FindElements(By.TagName("a")))
            {
                href = item.Text;
                _linksTableHeaderCollection.Add(new LinksTableHeaderCollection
                {
                    LinkText = href
                });
            }
            int j = 0;

            for (var i = 0; i < _linksTableHeaderCollection.Count; i++)
            {
                var text  = _linksTableHeaderCollection[i].LinkText.ToString();
                var linkf = driver.FindElement(By.LinkText(text));
                ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].style.visibility = 'visible'; arguments[0].style.display = 'block';", linkf);
                ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].click();", linkf);
                SeleniumGetMethod.WaitForPageLoad(driver);
                j++;
                //PropertiesCollection._reportingTasks.Log(Status.Info, text);

                //SeleniumGetMethod.WaitForPageLoad(driver);
            }
            Assert.AreEqual(j, _linksTableHeaderCollection.Count, "Count of links are DIFFERENT!!!");
        }
示例#2
0
        public static int DragDropHeaderTable(IWebDriver driver, IWebElement table)
        {
            var    Rows = table.FindElements(By.TagName("tr"));
            string href = "";

            foreach (IWebElement item in Rows[0].FindElements(By.TagName("a")))
            {
                href = item.Text;
                _linksTableHeaderCollection.Add(new LinksTableHeaderCollection
                {
                    LinkText = href
                });
            }
            int j = 0;

            for (var i = 0; i < _linksTableHeaderCollection.Count; i++)
            {
                var         text  = _linksTableHeaderCollection[i].LinkText.ToString();
                var         linkf = driver.FindElement(By.LinkText(text));
                IWebElement drag  = linkf;
                IWebElement drop  = driver.FindElement(By.CssSelector("#ctrGrid_RadGridStyles_GroupPanel_TB > tbody > tr > td > table"));

                (new Actions(driver)).ClickAndHold(drag).MoveToElement(drop).DragAndDrop(drag, drop).Perform();
                SeleniumGetMethod.WaitForPageLoad(driver);
                j++;
                //PropertiesCollection._reportingTasks.Log(Status.Info, text);

                //SeleniumGetMethod.WaitForPageLoad(driver);
            }
            Assert.AreEqual(j, _linksTableHeaderCollection.Count, "Count of links are DIFFERENT!!!");
            return(j);
        }
示例#3
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));
     }
 }
示例#4
0
        //[TestCaseSource(typeof(TestDataSource), nameof(TestDataSource.GetStyleHeadersData))]
        public void CheckExistsValidatorCreateStyle()
        {
            //Init Driver go to URL
            //SetUp(browserName,user);

            //Insert Data for Login Table in DB
            _reportingTasks.Log(Status.Debug, "INSERT VALUE TO LOGIN TABLE ");
            PostGreSQL pgTest = new PostGreSQL();

            //pgTest.PostgreTestInsert();
            //Select from Login Table in DB
            //dataItems = pgTest.PostgreSQLtest1();

            SeleniumGetMethod.WaitForPageLoad(driver);
            // Go To Style Folder
            var pageStyle = _pages.GetPage <PageObjectStyle>();

            _reportingTasks.Log(Status.Info, "UserAuto go to Style Folder " + "<br>" + driver.Url + "</br>");
            pageStyle.OpenStyle();

            //Go to Style New
            var pageNew = _pages.GetPage <PageObjectStyle>().ClickNewStyle();

            //Check page New Header
            pageNew.CheckValidators();
        }
示例#5
0
        public void TestMoneyTransaction()
        {
            Thread.Sleep(2000);

            foreach (var pencil in PencilsCredCardAndWiretransferDetails)
            {
                pencil.Click();
            }
            SeleniumGetMethod.WaitForPageLoad(driver);

            foreach (var input in AllInputsCredCardWiretransfer)
            {
                input.SendKeys(Helpers.Randomizer.String(5, letters) + Helpers.Randomizer.String(3, digits));
                Thread.Sleep(1000);
            }

            foreach (var drl in AllDropDownsCredCardWiretransfer)
            {
                SeleniumSetMethods.SelectDropDownRandom(drl);
                Thread.Sleep(1000);
            }

            foreach (var apply in BtnApplyFor2Forms)
            {
                apply.Click();
                Thread.Sleep(2000);
            }
            SeleniumGetMethod.WaitForPageLoad(driver);
            Thread.Sleep(2000);
        }
 public void SwitchToMenu()
 {
     SeleniumGetMethod.WaitForPageLoad(driver);
     SwitchToFrameHelper.ToDefaultContext(driver);
     SwitchToFrameHelper.ToMainBody(driver);
     SwitchToFrameHelper.ToLeftMenu(driver);
     btnStyleDeskNew.Click();
 }
示例#7
0
        public void ClickByRight(IList <IWebElement> elements, IList <IWebElement> elementsMen, int itemToClick)

        {
            int quantToSort = elements.Count();
            IList <IWebElement> itemsThatGrouped = PropertiesCollection.driver.FindElements(By.CssSelector(".rgGroupItem"));
            int countClicks = 0;

            for (int i = 0; i < quantToSort; i++)
            {
                IList <IWebElement> toClick = elements;
                (new Actions(PropertiesCollection.driver)).ContextClick(toClick[i]).Perform();
                SeleniumGetMethod.WaitForPageLoad(PropertiesCollection.driver);
                Thread.Sleep(2000);
                new WebDriverWait(PropertiesCollection.driver, TimeSpan.FromSeconds(3000)).Until(ExpectedConditions.ElementToBeClickable(elementsMen[itemToClick]));

                elementsMen[itemToClick].Click();
                SeleniumGetMethod.WaitForPageLoad(PropertiesCollection.driver);
                //for sorting - is column sorted
                if (itemToClick == 0 || itemToClick == 1)
                {
                    string afterColor = toClick[i].GetAttribute("style");
                    Assert.IsTrue(afterColor.Contains("background-color: rgb"));
                    countClicks++;
                }
            }
            //check sort quantity - logical test
            if (itemToClick == 0 || itemToClick == 1)
            {
                Assert.IsTrue(quantToSort == countClicks);
                PropertiesCollection._reportingTasks.Log(Status.Info, "<b>" + "There clicks to sort and number columns" + "<br>" + countClicks + "<br>" + quantToSort + "<b>");
            }
            //count clicked element if group - logic test
            if (itemToClick == 3)
            {
                int unGrouped = 0;
                IList <IWebElement> doneClick = PropertiesCollection.driver.FindElements(By.CssSelector(".rgGroupItem"));
                int toUngroup = doneClick.Count();
                for (int i = toUngroup - 1; i >= 0; i--)
                {
                    IList <IWebElement> beforeUngroup  = PropertiesCollection.driver.FindElements(By.CssSelector(".rgGroupItem"));
                    IList <IWebElement> toClickUngroup = elements;
                    (new Actions(PropertiesCollection.driver)).ContextClick(toClickUngroup[i]).Perform();
                    SeleniumGetMethod.WaitForPageLoad(PropertiesCollection.driver);
                    Thread.Sleep(2000);
                    new WebDriverWait(PropertiesCollection.driver, TimeSpan.FromSeconds(3000)).Until(ExpectedConditions.ElementToBeClickable(elementsMen[4]));
                    elementsMen[4].Click();
                    Thread.Sleep(2000);
                    IList <IWebElement> afterClick = PropertiesCollection.driver.FindElements(By.CssSelector(".rgGroupItem"));
                    if (beforeUngroup.Count() - afterClick.Count() == 1)
                    {
                        unGrouped++;
                    }
                    SeleniumGetMethod.WaitForPageLoad(PropertiesCollection.driver);
                }
                Assert.IsTrue(toUngroup == unGrouped);
                PropertiesCollection._reportingTasks.Log(Status.Info, "<b>" + "headers clickable : " + quantToSort + "<br> headers to ungroup : " + toUngroup + "<br> ungroup clicked : " + unGrouped + "</b>");
            }
        }
示例#8
0
 public virtual void CheckSearch()
 {
     foreach (var drl in SearchFormDropDowns)
     {
         SeleniumSetMethods.SelectDropDown(drl, 1);
         SeleniumGetMethod.WaitForPageLoad(driver);
         Thread.Sleep(2000);
     }
     foreach (var field in SearchFormInputs)
     {
         field.SendKeys(Helpers.Randomizer.String(7));
     }
     SeleniumGetMethod.WaitForPageLoad(driver);
     Thread.Sleep(3000);
     for (int i = 0; i < SearchFormCreatedDate.Count; i++)
     {
         SeleniumGetMethod.WaitForElement(driver, SearchFormCreatedDate[i]);
         SearchFormCreatedDate[i].Click();
         try
         {
             foreach (var date in CalendarBoxFromTo)
             {
                 if (date.Displayed)
                 {
                     date.Clear();
                     date.SendKeys(WindowsMessages.GetCurDate(1));
                     SeleniumGetMethod.WaitForPageLoad(driver);
                 }
             }
             if (BtnApply[i].Displayed)
             {
                 SeleniumGetMethod.WaitForElement(driver, BtnApply[i]);
                 BtnApply[i].Click();
                 SeleniumGetMethod.WaitForPageLoad(driver);
                 Thread.Sleep(1000);
                 SeleniumGetMethod.WaitForPageLoad(driver);
             }
         }
         catch (Exception msg)
         {
             PropertiesCollection._reportingTasks.Log(Status.Info, "Can't manipulate calendarboxes..<br>" + msg.ToString());
         }
     }
     Thread.Sleep(2000);
     BtnSearch.Click();
     SeleniumGetMethod.WaitForPageLoad(driver);
     Thread.Sleep(2000);
     try
     {
         xClearAllFilters.Click();
         Thread.Sleep(2000);
     }
     catch (Exception msg)
     {
         PropertiesCollection._reportingTasks.Log(Status.Info, "Can't set null filters uisng x(cross) link...<br>" + msg.ToString());
     }
     SeleniumGetMethod.WaitForPageLoad(driver);
 }
        public void OpenStyle()
        {
            //btnStyleDesk.Click();
            SwitchToMenu();

            SeleniumGetMethod.WaitForPageLoad(driver);
            //new WebDriverWait(driver, TimeSpan.FromSeconds(6000)).Until(ExpectedConditions.ElementExists((By.Id("lblHeader"))));
            //Assert.AreEqual("Style Folder", lblHeader.Text, "Text not found!!!");
        }
示例#10
0
 public void CheckSearchMenu(InputData dataForTest)
 {
     SwitchToMain();
     //spanSearch.Click();
     SeleniumGetMethod.WaitForPageLoad(driver);
     txtSearchName.EnterText(dataForTest.TxtSearchName);
     btnSaveSearch.Click();
     //spanSearch.Click();
     btnSearch.Click();
 }
示例#11
0
 public void OpenTargetSubfolder(IWebElement folderToOpen, IList <IWebElement> folderItems, int indexItemToOpen)
 {
     SeleniumGetMethod.WaitForPageLoad(PropertiesCollection.driver);
     //(new Actions(PropertiesCollection.driver)).MoveToElement(folderToOpen).Perform();
     folderToOpen.Click();
     SeleniumGetMethod.WaitForElement(PropertiesCollection.driver, folderItems.Last());
     PropertiesCollection._reportingTasks.Log(Status.Info, "<b> Folder to open:  </b>:  " + "<h5>" + folderToOpen.Text + " ---> " + folderItems[indexItemToOpen].Text + "</h5>");
     folderItems[indexItemToOpen].Click();
     SeleniumGetMethod.WaitForPageLoad(PropertiesCollection.driver);
     Thread.Sleep(2000);
 }
示例#12
0
        public void CheckCreateStyle(StyleHeaderData data)
        {
            SeleniumGetMethod.WaitForPageLoad(driver);
            // Go To Style Folder
            var pageStyle = _pages.GetPage <PageObjectStyle>();

            _reportingTasks.Log(Status.Info, "UserAuto go to Style Folder " + "<br>" + driver.Url + "</br>");
            pageStyle.OpenStyle();

            //Go to Style New
            var pageNew = _pages.GetPage <PageObjectStyle>().ClickNewStyle();

            //Check page New Header
            pageNew.Createpage(data);
            driver.SwitchTo().Window(pageNew.WindowHandle).Close();
        }
示例#13
0
 //for future testing
 public void CheckFilters()
 {
     CreateFiltA.Click();
     Thread.Sleep(3000);
     for (int i = 0; i < FiltersDrls.Count; i++)
     {
         var allFlters = driver.FindElements(By.CssSelector("div.item.choosen-columns select[name]"));
         if (SeleniumGetMethod.GetQuantityOfOptionsInDropDown(allFlters[i]) < 2)
         {
             break;
         }
         SeleniumSetMethods.SelectDropDown(allFlters[i], i + 1);
         Thread.Sleep(2000);
     }
     BtnCancel.Click();
     Thread.Sleep(2000);
 }
        public void CheckValidators()
        {
            var textHeaderNew = driver.Title;

            Assert.AreEqual("New Style", textHeaderNew, "Text not found!!!");
            PropertiesCollection._reportingTasks.Log(Status.Info, "UserAuto go to Page " + textHeaderNew + "<br>" + driver.Url + "</br>");
            btnNext.Click();
            PropertiesCollection._reportingTasks.Log(Status.Info, "UserAuto Click the btnNext " + textHeaderNew + "<br>" + driver.Url + "</br>");
            //Check Validators
            new WebDriverWait(driver, TimeSpan.FromSeconds(3000)).Until(ExpectedConditions.ElementIsVisible((By.Id("ctl13"))));
            error_icon.Click();
            bool isValidatorDisplayed = error_icon.Displayed;

            Assert.AreEqual(true, isValidatorDisplayed, "Validator wasn't find");
            //Click btn Close
            SeleniumGetMethod.WaitForPageLoad(driver);
            PropertiesCollection._reportingTasks.Log(Status.Info, "UserAuto click button Close");
            btnClose.Click();
        }
示例#15
0
        public void DragDrop()
        {
            SwitchToMain();
            var countColumDrag = WebTable.DragDropHeaderTable(driver, table);

            SeleniumGetMethod.WaitForPageLoad(driver);
            int countDropCross = cross.Count;

            Assert.AreEqual(countColumDrag, countDropCross, "Count Drag Colum are not equal Count crosses ");
            int k = 0;

            for (var i = 0; i < countDropCross; i++)
            {
                //cross[i].Click();
                var cr = driver.FindElement(By.ClassName("rgUngroup"));
                ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].click();", cr);
                SeleniumGetMethod.WaitForPageLoad(driver);
                ++k;
            }
            Assert.AreEqual(countDropCross, k, "The number of clicks on crosses is not equal to the number of crosses found");
        }
示例#16
0
        public virtual void CheckSort()
        {
            IList <IWebElement> gridHeaders = driver.FindElements(By.CssSelector("tr.jsgrid-header-row > th[class*=sortable]> div > div.text-ellipsis > span"));

            //ASC
            for (int i = 0; i < gridHeaders.Count; i++)
            {
                SeleniumGetMethod.WaitForElement(driver, gridHeaders[i]);
                gridHeaders[i].Click();
                SeleniumGetMethod.WaitForPageLoad(driver);
                SeleniumGetMethod.WaitForElement(driver, gridHeaders[i]);
                Thread.Sleep(2000);
                //DESC
                gridHeaders[i].Click();
                SeleniumGetMethod.WaitForPageLoad(driver);
                SeleniumGetMethod.WaitForElement(driver, gridHeaders[i]);
                Thread.Sleep(2000);
                var text = gridHeaders[i].GetAttribute("textContent");
                PropertiesCollection._reportingTasks.Log(Status.Info, "Sort by column" + " " + (i + 1) + " column name is " + text);
            }
        }
示例#17
0
        public void ExcelNewCheck()
        {
            string browserName = (String)((IJavaScriptExecutor)driver).ExecuteScript("return navigator.userAgent;");
            int    quantityFilesBefore = 0, quantityFilesAfter = 0;
            string path1, path2, path = "pathToFile";

            if (browserName.Contains("Chrome"))
            {
                path1 = Path.GetDirectoryName(Assembly.GetCallingAssembly().CodeBase);
                path2 = path1.Substring(0, path1.IndexOf("bin")) + ("Downloads\\");
                path  = new Uri(path2).LocalPath;
                string[] filePaths = Directory.GetFiles(path);
                quantityFilesBefore = filePaths.Count();
            }
            else
            {
                PropertiesCollection._reportingTasks.Log(Status.Info, description: "Works only in Chrome");
            }
            SwitchToMain();
            SeleniumGetMethod.WaitForPageLoad(driver);
            ((IJavaScriptExecutor)PropertiesCollection.driver).ExecuteScript("arguments[0].click();", ViewExpander[0]);
            System.Threading.Thread.Sleep(3000);
            ((IJavaScriptExecutor)PropertiesCollection.driver).ExecuteScript("arguments[0].click();", ListViewClicker[0]);
            new WebDriverWait(PropertiesCollection.driver, TimeSpan.FromSeconds(3000)).Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("#ctrGrid_RadGridStyles_ctl00 > thead > tr > th:nth-child(1) > a")));
            ((IJavaScriptExecutor)PropertiesCollection.driver).ExecuteScript("arguments[0].click();", ExpandToolsForExcel[0]);
            System.Threading.Thread.Sleep(3000);
            ((IJavaScriptExecutor)PropertiesCollection.driver).ExecuteScript("arguments[0].click();", NewJsExcel[0]);
            new WebDriverWait(PropertiesCollection.driver, TimeSpan.FromSeconds(3000)).Until(ExpectedConditions.ElementToBeClickable(ExcelExpCloseWaitSpinner[0]));
            ExcelExpCloseWaitSpinner[0].Click();
            if (browserName.Contains("Chrome"))
            {
                quantityFilesAfter = Directory.GetFiles(path).Count();
                Assert.IsTrue(quantityFilesAfter > quantityFilesBefore, "Yes, downloading works");
                PropertiesCollection._reportingTasks.Log(Status.Info, description: "Files founded BEFORE: " + quantityFilesBefore.ToString() + "<br>" + " Files founded AFTER : " + quantityFilesAfter.ToString());
            }
            else
            {
                PropertiesCollection._reportingTasks.Log(Status.Info, description: "Works only in Chrome");
            }
        }
示例#18
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);
        }
示例#19
0
        public void CheckGettingDate()
        {
            SwitchToMain();
            WindowsMessages windowsMessages = new WindowsMessages();

            CalBoxTechPack.SendKeys(windowsMessages.GetCurDate(1));
            btnSearch.Click();
            SeleniumGetMethod.WaitForPageLoad(PropertiesCollection.driver);
            CalBoxTechPack.Clear();
            CalBoxTechPack.SendKeys(windowsMessages.GetCurDate(2));
            btnSearch.Click();
            Thread.Sleep(2000);
            CalBoxTechPack.Clear();
            CalBoxTechPack.SendKeys(windowsMessages.GetCurDate(3));
            btnSearch.Click();
            Thread.Sleep(2000);
            CalBoxTechPack.Clear();
            CalBoxTechPack.SendKeys(windowsMessages.GetCurDate(4));
            btnSearch.Click();
            Thread.Sleep(2000);
            CalBoxTechPack.Clear();
            btnSearch.Click();
        }
示例#20
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);
        }
        public void Createpage(StyleHeaderData data)
        {
            var textHeaderNew = driver.Title;

            Assert.AreEqual("New Style", textHeaderNew, "Text not found!!!");
            PropertiesCollection._reportingTasks.Log(Status.Info, "UserAuto go to Page " + textHeaderNew + "<br>" + driver.Url + "</br>");

            if (!string.IsNullOrWhiteSpace(data.Division))
            {
                new SelectElement(drlDivisionID).SelectByText(data.Division);
            }
            if (!string.IsNullOrWhiteSpace(data.StyleType))
            {
                new SelectElement(drlStyleType).SelectByText(data.StyleType);
            }
            if (!string.IsNullOrWhiteSpace(data.WorkflowType))
            {
                new SelectElement(drlWorkflowType).SelectByText(data.WorkflowType);
            }

            if (!string.IsNullOrWhiteSpace(data.IntroSeasonYear))
            {
                new SelectElement(isyDropDown).SelectByText(data.IntroSeasonYear);
            }
            else
            {
                SeleniumSetMethods.SelectDropDown(isyDropDown, 2);
            }
            if (!string.IsNullOrWhiteSpace(data.Calendar))
            {
                new SelectElement(drlCalendar).SelectByText(data.Calendar);
            }
            btnNext.Click();
            SeleniumGetMethod.WaitForPageLoad(driver);

            if (!string.IsNullOrWhiteSpace(data.StyleNo))
            {
                new SelectElement(noStyles).SelectByText(data.StyleNo);
            }
            if (!string.IsNullOrWhiteSpace(data.StyleSet))
            {
                new SelectElement(drlStyleSet).SelectByText(data.StyleSet);
            }
            if (!string.IsNullOrWhiteSpace(data.StyleCategory))
            {
                new SelectElement(syleCategoryDropDown).SelectByText(data.StyleCategory);
            }
            else
            {
                SeleniumSetMethods.SelectDropDown(syleCategoryDropDown, 2);
                new WebDriverWait(driver, TimeSpan.FromSeconds(500)).Until(ExpectedConditions.ElementIsVisible((By.Id("btnSaveStyle"))));
            }
            if (!string.IsNullOrWhiteSpace(data.SizeClass))
            {
                SeleniumGetMethod.WaitForPageLoad(driver);
                new SelectElement(drlSizeClassId).SelectByText(data.SizeClass);
            }
            if (!string.IsNullOrWhiteSpace(data.SizeRange))
            {
                SeleniumGetMethod.WaitForPageLoad(driver);
                new SelectElement(drlSizeRangeId).SelectByText(data.SizeRange);
            }
            if (!string.IsNullOrWhiteSpace(data.Description))
            {
                SeleniumGetMethod.WaitForPageLoad(driver);
                txtDescription.SendKeys(data.Description);
            }
            if (!string.IsNullOrWhiteSpace(data.Active))
            {
                SeleniumGetMethod.WaitForPageLoad(driver);
                new SelectElement(drlActive).SelectByText(data.Active);
            }

            SeleniumGetMethod.WaitForPageLoad(driver);
            btnSaveStyle.Click();
            Thread.Sleep(5000);
            Assert.AreNotEqual(driver.Title, "New Style");
        }
示例#22
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);
        }