Selenium Webdriver Program

Write a program in Selenium webdriver to check the current page number by total number of pages visible at the bottom of each page in an application. Assume there are 100 pages. Ex: 10/100, 11/100 etc.

Showing Answers 1 - 2 of 2 Answers


  • Sep 13th, 2016

String str=driver.findElement("someid")).getText();
String arr[]=str.split("/");
System.out.println("The current page number is "+arr[0]);

  Was this answer useful?  Yes

// This program prints 3/75 3 is the current page and 75 is the last
//we just did gettext for both elements and printed
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
public class CurrentPageTotalPage {
public static void main(String[] args) {
// TODO Auto-generated method stub
// System.out.println(" The current and total pages are " + result);
System.setProperty("", "D:\software\chromedriver_win32\chromedriver.exe");
WebDriver drv = new ChromeDriver();

WebElement el1 = drv.findElement(By.className("pagnCur"));
WebElement el2 = drv.findElement(By.className("pagnDisabled"));

String result=el1.getText()+ "/" + el2.getText();

System.out.println(" The current and total pages are " + result);

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.


Related Answered Questions


Related Open Questions