Code for to get list from google screen for all links.....
importorg.openqa.selenium.WebDriver;
import org.openqa.selenium. WebElement;
import org.openqa.selenium.chrome. ChromeDriver;
public class Test {
public static voidmain(String[] args) {
System.setProperty("webdriver. chrome.driver","C://Users// ylondhe//Documents//Backup// Documents//chromedriver.exe");
WebDriver driver = newChromeDriver();
java.util.List<WebElement> links =driver.findElements(By.tagName ("a"));
System.out.println("num of links in screen : " + links.size());
boolean map= false;
for(WebElements:links){
System.out.println(s.getText( ));
if(s.getText().equalsIgnoreCase( "Maps")){
map=true;
break;
}
}
System.out.println(map);
driver.quit();
}
}
No comments:
Post a Comment