Note- code has been done in such a way so that it will not print those title which are blank.
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.
WebElement;
import org.openqa.selenium.firefox. FirefoxDriver;
public class Deepika {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts(). implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://www. swissoutpost.com/");
List<WebElement> imgs = driver.findElements(By. tagName("img"));
System.out.println(imgs.size() );
int num =0;
String toolTip="";
for(int i=0; i<imgs.size(); i++){
toolTip = imgs.get(i).getAttribute(" title");
num+=1;
if(toolTip.equals("")){
}else{
System.out.println(toolTip);
}
}
System.out.println(num);
}
}
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.
import org.openqa.selenium.firefox.
public class Deepika {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().
driver.get("http://www.
List<WebElement> imgs = driver.findElements(By.
System.out.println(imgs.size()
int num =0;
String toolTip="";
for(int i=0; i<imgs.size(); i++){
toolTip = imgs.get(i).getAttribute("
num+=1;
if(toolTip.equals("")){
}else{
System.out.println(toolTip);
}
}
System.out.println(num);
}
}
No comments:
Post a Comment