0

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 ?

AppiumUser
  • 53
  • 3
  • 8

2 Answers2

0

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);
demongolem
  • 9,474
  • 36
  • 90
  • 105
Danny
  • 287
  • 2
  • 15
-1

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