Italian Trulli

How to Get Count of Element in Selenium Using Java

Test Tribe
.

 How To Get Elements Count on Webpage in Java & Selenium?

Get Count of element in Selenium 


  • How to Get Count of Check Box Available in Selenium Using Java?

Selenium Code:

public class GetCountofElement {


public static void main(String[] args) {

// TODO Auto-generated method stub

System.setProperty("webdriver.chrome.driver","C:\\Users\\Admin\\Downloads\\chromedriver-win64 (1)\\chromedriver-win64\\chromedriver.exe");

WebDriver driver = new ChromeDriver();

driver.get("https://rahulshettyacademy.com/dropdownsPractise/");

List<WebElement> opt= driver.findElements(By.cssSelector("input[type='checkbox']"));

int a= opt.size();

System.out.println("Total Count="+a);


}


}


The Above Selenium Code Will Return the Total Count of Text Boxes presented on the Gmail Signup Page.


  • How To Get the Count of Text Box Present in Selenium WebDriver Using Java?

public class CheckBox {


public static void main(String[] args) {

// TODO Auto-generated method stub

System.setProperty("webdriver.chrome.driver","C:\\Users\\Admin\\Downloads\\chromedriver-win64 (1)\\chromedriver-win64\\chromedriver.exe");

WebDriver driver = new ChromeDriver();

driver.get("https://accounts.google.com/signup/v2/createaccount?theme=glif&flowName=GlifWebSignIn&flowEntry=SignUp");

List<WebElement> opt= driver.findElements(By.cssSelector("input[type='text']"));

int a= opt.size();

System.out.println("Total Count="+a);


}


}


The Above Selenium Code Will Return the Total Count of Text Boxes presented on the Gmail Signup Page.

Post a Comment

0 Comments