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 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();
}

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

| improve this answer | |
  • Hi @Moro , I have try as you said but got no any solution :( – Rahul Kumar Dec 2 '19 at 13:02
  • Hey @Moro , Please guide me further what should i have to do i am stuck on it. – Rahul Kumar Dec 6 '19 at 9:05
  • Have you tried simply clicking the desired Element from the list? I do not use appium, so despite the fact that you are capturing wrong element for a Select list I am not sure I can be of any help. – Moro Dec 6 '19 at 10:11
  • Yes sir, i have tried not working but its ok. and Thanks for your valuable response :) – Rahul Kumar Dec 6 '19 at 10:44
  • Hi @Moro, can you please someone tag this issue to help me. I am totally stuck on it. – Rahul Kumar Jan 17 at 7:52

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.