public class NumberofLinks {
public static void main(String[] args) throws InterruptedException {
int enable=0;
int disable=0;
WebDriver d = new FirefoxDriver();
d.manage().window().maximize();
d.manage().timeouts().implicitlyWait(45, TimeUnit.SECONDS);
d.get("https://www.google.com");
d.findElement(By.name("q")).sendKeys("selenium");
Thread.sleep(2000);
List<WebElement> elements=d.findElements(By.tagName("a"));
System.out.println(elements.size());
for (WebElement webElement : elements) {
if (webElement.isEnabled()) {
enable++;
}
else {
disable++;
}
}
System.out.println("enable links are:"+enable);
System.out.println("disable links are:"+disable);
Thread.sleep(5000);
}
}
public static void main(String[] args) throws InterruptedException {
int enable=0;
int disable=0;
WebDriver d = new FirefoxDriver();
d.manage().window().maximize();
d.manage().timeouts().implicitlyWait(45, TimeUnit.SECONDS);
d.get("https://www.google.com");
d.findElement(By.name("q")).sendKeys("selenium");
Thread.sleep(2000);
List<WebElement> elements=d.findElements(By.tagName("a"));
System.out.println(elements.size());
for (WebElement webElement : elements) {
if (webElement.isEnabled()) {
enable++;
}
else {
disable++;
}
}
System.out.println("enable links are:"+enable);
System.out.println("disable links are:"+disable);
Thread.sleep(5000);
}
}
No comments:
Post a Comment