import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class DropDownTest {
public static void main(String[] args) {
WebDriver myTestDriver = new FirefoxDriver();
myTestDriver.get("http://www.shine.com/partnersites/");
// DropDown
myTestDriver.findElement(By.className("cls_ulAdvSearch_a")).click();
myTestDriver.findElement(By.id("id_ffunc_area_text")).sendKeys("Quality / Testing (QA-QC)");
myTestDriver.findElement(By.id("id_findustry")).sendKeys("IT - Software");
myTestDriver.findElement(By.className("redbtn cls_btn_reg_job_srch_lrg")).click();
List<WebElement> Industry = myTestDriver.findElement(By.id("id_ffunc_area_text")).findElements(By.tagName("option"));
System.out.println(Industry.size());
for(int i = 0; i< Industry.size();i++){
System.out.println(Industry.get(i).getText() +"--------------> "+ Industry.get(i).getAttribute("value"));
}
}
}
Follow @TestingQ
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class DropDownTest {
public static void main(String[] args) {
WebDriver myTestDriver = new FirefoxDriver();
myTestDriver.get("http://www.shine.com/partnersites/");
// DropDown
myTestDriver.findElement(By.className("cls_ulAdvSearch_a")).click();
myTestDriver.findElement(By.id("id_ffunc_area_text")).sendKeys("Quality / Testing (QA-QC)");
myTestDriver.findElement(By.id("id_findustry")).sendKeys("IT - Software");
myTestDriver.findElement(By.className("redbtn cls_btn_reg_job_srch_lrg")).click();
List<WebElement> Industry = myTestDriver.findElement(By.id("id_ffunc_area_text")).findElements(By.tagName("option"));
System.out.println(Industry.size());
for(int i = 0; i< Industry.size();i++){
System.out.println(Industry.get(i).getText() +"--------------> "+ Industry.get(i).getAttribute("value"));
}
}
}