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

asked Dec 2, 2019 at 10:25

1 Answer 1

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

answered Dec 2, 2019 at 12:38
5
  • Hi @Moro , I have try as you said but got no any solution :( Commented Dec 2, 2019 at 13:02
  • Hey @Moro , Please guide me further what should i have to do i am stuck on it. Commented Dec 6, 2019 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. Commented Dec 6, 2019 at 10:11
  • Yes sir, i have tried not working but its ok. and Thanks for your valuable response :) Commented Dec 6, 2019 at 10:44
  • Hi @Moro, can you please someone tag this issue to help me. I am totally stuck on it. Commented Jan 17, 2020 at 7:52

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.