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();
}
1 Answer 1
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– Rahul Kumar2019年12月02日 13:02:20 +00:00Commented Dec 2, 2019 at 13:02
-
Hey @Moro , Please guide me further what should i have to do i am stuck on it.Rahul Kumar– Rahul Kumar2019年12月06日 09:05:43 +00:00Commented 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 aSelect
list I am not sure I can be of any help.Moro– Moro2019年12月06日 10:11:47 +00:00Commented Dec 6, 2019 at 10:11 -
Yes sir, i have tried not working but its ok. and Thanks for your valuable response :)Rahul Kumar– Rahul Kumar2019年12月06日 10:44:55 +00:00Commented Dec 6, 2019 at 10:44
-
Hi @Moro, can you please someone tag this issue to help me. I am totally stuck on it.Rahul Kumar– Rahul Kumar2020年01月17日 07:52:56 +00:00Commented Jan 17, 2020 at 7:52
Explore related questions
See similar questions with these tags.