I am new to Selenium, currently am working on selenium webdriver. I want to select a value from the drop-down. But I am not able to do it because of some error. Also, I want to inform you that in my automator viewer I have not found any id of the dropdown element hence I am using with XPath but I am not able to do please guide me. My java code is below:
@Test
public void print() throws Exception
{
WebDriverWait wait = new WebDriverWait(driver, 60);// 1 minute
wait.until(ExpectedConditions.visibilityOfElementLocated(By.className(“android.widget.Button”)));
driver.findElementByClassName(“android.widget.EditText”).sendKeys(“1234567890”);
driver.hideKeyboard();
Select drpCountry = new Select(driver.findElement(By.xpath(“//android.widget.ImageView[@index=’2′]”)));
drpCountry.selectByVisibleText(“+91(IN)”);
drpCountry.selectByIndex(8);
driver.findElementByClassName(“android.widget.Button”).click();
}
Source: Read More