package
pack3;
import
java.util.List;
import
org.openqa.selenium.By;
import
org.openqa.selenium.WebElement;
import
org.openqa.selenium.firefox.FirefoxDriver;
public class
CaptureLinksIn Header {
public static void
main(String[] args) {
System.setProperty("webdriver.gecko.driver", "C:/path/geckodriver.exe");
FirefoxDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.get("http://www.bing.com/");
WebElement header = driver.findElement(By.id("sc_hdu"));
List<WebElement> links = header.findElements(By.tagName("a"));
System.out.println(links.size());
for(int i=0;i<links.size();i++)
{
System.out.println(links.get(i).getText());
}
}
}This program will capture all links of header section.
No comments:
Post a Comment