Tuesday, 20 March 2012

Xpath Count in Selenium2 WebDriver

Selenium 1 uses 'getXpathCount' method to find the Xpath count of an atribute in the screen.
But in Selenium2 webdriver it is done by the following way:

int xpathCount= webDriver.findElements(By.xpath("//div[@id='billingProfiles']/div[@class='cardContainer']")).size();

please note that we are using 'findElements' instead of the usual 'findElement' method.