package selenium_examples;
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 spicejet {
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);
WebElement we = driver.findElement(By.name("fromPort"));
java.util.List options = we.findElements(By.tagName("option"));
System.out.println("Dropdown values count = " + options.size());
driver.close();
}
}
Output :-
Dropdown values count = 10
Above script logins into Mercury tours website and gets count of number of drop down values present in "Departing From" dropdown 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 spicejet {
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);
WebElement we = driver.findElement(By.name("fromPort"));
java.util.List
System.out.println("Dropdown values count = " + options.size());
driver.close();
}
}
Output :-
Dropdown values count = 10
Above script logins into Mercury tours website and gets count of number of drop down values present in "Departing From" dropdown list.
No comments:
Post a Comment