import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class GetLinksCount {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver",System.getProperty("user.dir")+"//drivers/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.flipkart.com/");
String newwindow = driver.getWindowHandle();
driver.switchTo().window(newwindow);
driver.findElement(By.xpath("//button[@class='_2AkmmA _29YdH8']")).click();
List<WebElement> links = driver.findElements(By.tagName("a")); //This will store all links in links object.
System.out.println(links.size()); //Use size method to get count
driver.quit();
}
}
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class GetLinksCount {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver",System.getProperty("user.dir")+"//drivers/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.flipkart.com/");
String newwindow = driver.getWindowHandle();
driver.switchTo().window(newwindow);
driver.findElement(By.xpath("//button[@class='_2AkmmA _29YdH8']")).click();
List<WebElement> links = driver.findElements(By.tagName("a")); //This will store all links in links object.
System.out.println(links.size()); //Use size method to get count
driver.quit();
}
}
Superb Post on Selenium and JMeter
ReplyDeleteManual Testing Training in Chennai
QTP Training in Chennai
Selenium Training in Chennai
SoapUI Training in Chennai
Software Testing Training in Chennai