public void PreviousPage() { /* Test initialization */ IWebDriver driver = new ChromeDriver(); driver.Navigate().GoToUrl("https://www.olx.pl/warszawa/q-lodowka/"); List <IWebElement> pageChangeBar = new List <IWebElement>(driver.FindElements(By.XPath("//*[@id=\"body-container\"]/div[3]/div/div[8]"))); PageBar pageBar = new PageBar(driver); /* Testing */ Assert.That(pageBar.PageList.LastPageNumber, Is.EqualTo(19)); pageBar = pageBar.GoToLastPage(driver); pageBar = pageBar.GoToPreviousPage(driver); Assert.That(driver.Url, Is.EqualTo("https://www.olx.pl/warszawa/q-lodowka/?page=18")); Assert.That(pageBar.PageList.NumberOfPages, Is.EqualTo(12)); Assert.That(pageBar.PageList.FirstPageNumber, Is.EqualTo(1)); Assert.That(pageBar.NextPrev.IsNext(), Is.True); Assert.That(pageBar.NextPrev.IsPrevious(), Is.True); /* Teard down */ driver.Quit(); }
public void PageBar_GoToPreviousPage_Test_4() { using (var driver = new ChromeDriver()) { /* Initialization */ var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60)); driver.Manage().Window.Maximize(); driver.Navigate().GoToUrl("https://tms.lionbridge.com/"); string projectTitle = "Qlik"; ProjectsPage testPage = new ProjectsPage(driver, projectTitle); testPage.ClickChosenProject(); ParticularProjectPage testProjectPage = new ParticularProjectPage(driver); testProjectPage.ProfileClick(driver); testProjectPage.ChangeItemsPerPageMin(driver); testProjectPage.StatusClick(driver); StatusPage testStatusPage = new StatusPage(driver); PageBar testPageBar = new PageBar(driver); testPageBar.GoToLastPage(driver); testPageBar = new PageBar(driver); /* Set of assertions */ Assert.AreEqual(testPageBar.GetLastPageNumber, testPageBar.GetCurrentPageNumber); Assert.AreEqual(0, testPageBar.PreviousPageIsNull); Assert.AreEqual(1, testPageBar.NextPageIsNull); testPageBar.GoToFirstPage(driver); testPageBar = new PageBar(driver); Assert.AreEqual(0, testPageBar.CurrentPageIsNull); Assert.AreEqual(1, testPageBar.CurrentPageIsFirst); Assert.AreEqual(0, testPageBar.CurrentPageIsLast); Assert.AreEqual(1, testPageBar.GetCurrentPageNumber); Assert.AreEqual(1, testPageBar.PreviousPageIsNull); Assert.AreEqual(0, testPageBar.NextPageIsNull); testPageBar.GoToPreviousPage(driver); testPageBar = new PageBar(driver); Assert.AreEqual(0, testPageBar.CurrentPageIsNull); Assert.AreEqual(1, testPageBar.CurrentPageIsFirst); Assert.AreEqual(0, testPageBar.CurrentPageIsLast); Assert.AreEqual(1, testPageBar.GetCurrentPageNumber); Assert.AreEqual(1, testPageBar.PreviousPageIsNull); Assert.AreEqual(0, testPageBar.NextPageIsNull); } }
public void PreviousPageFor() { /* Test initialization */ IWebDriver driver = new ChromeDriver(); driver.Navigate().GoToUrl("https://www.olx.pl/warszawa/q-lodowka/"); List <IWebElement> pageChangeBar = new List <IWebElement>(driver.FindElements(By.XPath("//*[@id=\"body-container\"]/div[3]/div/div[8]"))); PageBar pageBar = new PageBar(driver); /* Testing */ pageBar = pageBar.GoToLastPage(driver); for (int i = pageBar.PageList.LastPageNumber - 1; i > 0; i--) { pageBar = pageBar.GoToPreviousPage(driver); Assert.That(pageBar.PageList.FirstPageNumber, Is.EqualTo(1)); if (i != 1) { Assert.That(driver.Url, Is.EqualTo("https://www.olx.pl/warszawa/q-lodowka/?page=" + i.ToString())); Assert.That(pageBar.NextPrev.IsNext(), Is.True); Assert.That(pageBar.NextPrev.IsPrevious(), Is.True); } else { Assert.That(driver.Url, Is.EqualTo("https://www.olx.pl/warszawa/q-lodowka/")); Assert.That(pageBar.NextPrev.IsNext(), Is.True); Assert.That(pageBar.NextPrev.IsPrevious(), Is.False); } } /* Teard down */ driver.Quit(); }