hound icon indicating copy to clipboard operation
hound copied to clipboard

select option

Open joshcrews opened this issue 9 years ago • 7 comments

Does hound have a function for selecting an option from a dropdown?

joshcrews avatar Feb 01 '16 16:02 joshcrews

I have been using straight CSS to get at it, seems to work, but sometimes it has locked up my Selenium...

Page.find_element(:css, "#select_id option[value='value']") |> Element.click

You can also fire jQuery in a pinch...

ScriptExecution.execute_script("<your jquery here>")

darksheik avatar Feb 01 '16 17:02 darksheik

@joshcrews the official webdriver API doesn't provide anything direct to deal with select boxes. We'll figure something out soon. Until then @darksheik's solution is the way to go. Will keep this issue open as a sign of todo.

@darksheik thanks for pitching in ~!

HashNuke avatar Feb 01 '16 22:02 HashNuke

Hi @joshcrews, Did you have any trouble simply using click? If you did, could you please let us know on what kind of dropdown? If not, I am not sure it is really a necessity to add something, as I think @darksheik solution is already simple enough. What you you think?

/cc @HashNuke

danhper avatar Apr 03 '16 16:04 danhper

The darksheik click worked

joshcrews avatar Apr 03 '16 16:04 joshcrews

@tuvistavie Since it is a common input element, we could add support for bare-html select boxes. Something like this maybe?

# select by value
Element.select(strategy, selector, value: value)

# select by option name
Element.select(strategy, selector, option: option_name)

Underneath it would do the same thing as @darksheik did it, select by value/label and click.

HashNuke avatar Apr 03 '16 16:04 HashNuke

👍

vitalis avatar Jul 28 '16 07:07 vitalis

I have a problem where material-ui makes a fixed dropdown that's similar to bootstraps modals for the visuals to click. Not sure what the best way to deal with this is.

UPDATE: I ended up doing something that worked but it's pretty gross.

category_field = find_within_element(form_drawer, :name, "category") click(category_field) category_option = find_element(:css, "div[style*='z-index: 1000; top: 0px; right: 0px;'] > div > div") click(category_option)

Thought I'd share.

jbhatab avatar Sep 25 '16 18:09 jbhatab