Can anyone help me solution for query
There are 2 dropdown. One dropdown contains all the "Countries" and 2nd dropdown contains all the "States". You have to fetch all the Values from "Country" Dropdow. Select the Country as "US" and have to Count,retrieve,verify all the "states"(in 2nd Dropdown) of Country("US"). I have Written the Code but can't complete
public class test {
static{
System.setProperty("webdriver.chrome.driver", "./drivers/chromedriver.exe");
System.setProperty("webdriver.gecko.driver", "./drivers/geckodriver.exe");
}
public static void main(String[] args) {
// TODO Auto-generated method stub
WebDriver driver= new FirefoxDriver();
driver.manage().window().maximize();
int count=0, total=0;
driver.get("file:///C:/Users/usetr/Desktop/Country.html");
WebElement alllistBox = driver.findElement(By.id("Country"));
Select slt = new Select(alllistBox);
//Select Country India
slt.selectByVisibleText("India");
//Printing All country in dropdown and thier counts
List<WebElement> alloptions = slt.getOptions();
for (WebElement option : alloptions) {
System.out.println(option.getText());
count++;
}
System.out.println("Number of country present " + count);
Count,retrieve,verify all the "states", Yes we canCountandretrievebut verify all the "states" with respect to what? Thanks