1

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 because of some error. Also want to inform you that in my automator viewer i have not find 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();
}

enter image description here

0

It seems that your Select element is one level above the thing you are capturing, try using xpath of the View above your ImageView

  • Hi @Moro , I have try as you said but got no any solution :( – Rahul Kumar Dec 2 at 13:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.