package selenium_examples;
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 Sample {
public static void main(String[] args)
{
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.get("http://newtours.demoaut.com/");
List linkElements = driver.findElements(By.tagName("a"));
System.out.println("Total number of Links ="+linkElements.size());
for(int i=0; i< linkElements.size(); i++)
{
System.out.println(linkElements.get(i).getText());
}
}
}
Output:-
Total number of Links =16
Home
Flights
Hotels
Car Rentals
Cruises
Destinations
Vacations
SIGN-ON
REGISTER
SUPPORT
CONTACT
your destination
featured vacation destinations
Register here
Business Travel @ About.com
Salon Travel
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 Sample {
public static void main(String[] args)
{
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.get("http://newtours.demoaut.com/");
List
System.out.println("Total number of Links ="+linkElements.size());
for(int i=0; i< linkElements.size(); i++)
{
System.out.println(linkElements.get(i).getText());
}
}
}
Output:-
Total number of Links =16
Home
Flights
Hotels
Car Rentals
Cruises
Destinations
Vacations
SIGN-ON
REGISTER
SUPPORT
CONTACT
your destination
featured vacation destinations
Register here
Business Travel @ About.com
Salon Travel
No comments:
Post a Comment