1

I'm trying to select a value from a textbox that display a list of suggestions when something is typed, I've tried:

$browser.li(:xpath, "//div[@id='question1']/div/div[2]/input").select 'Value 1'
$browser.li(:text, /Value/).select
$browser.li(:text, /Value/).click

With this one I get the list displayed when I set a string in the text field:

$browser.text_field(:name => 'choice').set("Value")

and I try to select a value with this one:

$browser.li(:text, /Value/).when_present.click

but none seems to work, I can manage to make the browser display the list, but I need to select one value from de list. Any idea?

Here's an example of the HTML of the list when it gets displayed:

<ul class="ui-autocomplete" role="listbox">
    <li class="ui-menu-item" role="menuitem"><a class="ui-corner-all" tabindex="-1">Value 1</a></li>
    <li class="ui-menu-item" role="menuitem"><a class="ui-corner-all" tabindex="-1">Value 2</a></li>
    <li class="ui-menu-item" role="menuitem"><a class="ui-corner-all" tabindex="-1">Value 3</a></li>
</ul>
Željko Filipin
  • 56,372
  • 28
  • 94
  • 125
Kelvin De Moya
  • 5,118
  • 1
  • 17
  • 16
  • You probably have to fire javascript event: http://stackoverflow.com/questions/3787555/how-to-find-out-which-javascript-events-fired – Željko Filipin May 18 '12 at 13:54
  • just to be clear (since a lot of folks are often confused by this), an LI tag is a "List Item" which is a kind of container element used to hold stuff in an Un-ordered List (UL tag). Inside those in your HTML above you have 'links' which are A (Anchor) tags. Anchor elements are what create 'hyper-links' in a 'hyper-text' web page, what everyone just calls 'links' for short, everyone except the people who created the HTML specifications that is.. – Chuck van der Linden May 23 '12 at 08:08

1 Answers1

3

Maybe try clicking the link instead of the list item?

$browser.link(:text, /Value/).when_present.click
Justin Ko
  • 46,526
  • 5
  • 91
  • 101