package selenium_examples;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
import java.util.concurrent.TimeUnit;
import java.util.List;
public class example1 {
public static void main(String[] args)
{
WebDriver driver = new FirefoxDriver();
driver.get("http://newtours.demoaut.com");
driver.findElement(By.name("userName")).sendKeys("mercury");
driver.findElement(By.name("password")).sendKeys("mercury");
driver.findElement(By.name("login")).click();
driver.manage().timeouts().implicitlyWait(100,TimeUnit.SECONDS);
Select droplist = new Select(driver.findElement(By.name("fromPort")));
droplist.selectByVisibleText("London");
WebElement we = driver.findElement(By.name("fromPort"));
List
for (WebElement option : options) {
System.out.println(option.getText());
}
}
}
Output will be :-
Acapulco
Frankfurt
London
New York
Paris
Portland
San Francisco
Seattle
Sydney
Zurich
Above script logins into Mercury tours website and selects value "London" from Departing From dropdown list and it displays all the options of dropdown list.
No comments:
Post a Comment