////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
import java.net.URL;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.
import org.openqa.selenium.chrome.
import org.openqa.selenium.firefox.
import org.openqa.selenium.firefox.
String baseUrl = "https://www.google.co.in/";
System.out.println("firefox");
FirefoxProfile firefoxprofile = new FirefoxProfile();
firefoxprofile.setPreference("
firefoxprofile.setPreference("
firefoxprofile.
DesiredCapabilities capability = DesiredCapabilities.firefox();
capability.setCapability(
capability.setBrowserName("
capability.setPlatform(org.
driver = new FirefoxDriver(capability);
driver.get(baseUrl);
int i=0;
List<WebElement> allElements = driver.findElements(By.xpath("
for (WebElement Element : allElements) {
i = i+1;
System.out.println(Element.
System.out.println(Element.
}
System.out.println("total objects founds " + i);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
here we are finding all the elements on page
List<WebElement> allElements = driver.findElements(By.xpath("//*"));
in case if you want to count all the links on page then use below code
List<WebElement> allElements = driver.findElements(By.xpath("//a"));
Or if you want to count all buttons on the page the use below code
List<WebElement> allElements = driver.findElements(By.xpath("//BUTTON"));
No comments:
Post a Comment