0
votes

I am trying to automate wikipedia - search text field - using selenium webdriver.

I want to send text "kin" into it and select value "kinu" from the autopopulated list.

HTML for input box:input type="search" dir="auto" accesskey="F" autofocus="autofocus" size="20" name="search" id="searchInput" results="10" autocomplete="off" list="suggestions"

is there any way to traverse through the list by using key down event and select value "kinu" from the list?

enter image description here

From firebug , i can see that HTML for this field "kinu" is <"option value="Kinu">.enter image description here

so i tried finding the value using xpath WebElement el1= driver.findElement(By.xpath("//option[@value='kinu']")); but i am not able to find it. is there any other way to get this ?

2
could you please edit your post, and include HTML, including the textbox, and the <select> element that you are trying to interact with? - ddavison
@sircapsalot:edited the post - AppiumUser

2 Answers

0
votes

You MAY need the driver to click the element first (auto complete box) then use the following:

driver.findElement(By.xpath("//input[contains(@id, 'searchInput')]")).sendKeys("Kinu" + Keys.ENTER);
-1
votes

Fastest way in my view:

driver.findElement(By.id("searchInput")).sendKeys("Kinu");

Good code example might be found there: Need to find element in selenium by css