hound
hound copied to clipboard
select option
Does hound have a function for selecting an option from a dropdown?
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>")
@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 ~!
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
The darksheik click worked
@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.
👍
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.