Created
October 15, 2018 19:43
-
-
Save glaszig/edef1f58ca62f1e58c724ad221563579 to your computer and use it in GitHub Desktop.
Method to set value of range input field with Capybara
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActionDispatch::IntegrationTest | |
# usage: set_range "My Range Field", to: 42 | |
# this also triggers the input's change and/or input events | |
# as opposed to find_field("My Range Field").set 42 | |
def set_range(locator = nil, to:, **find_options) | |
find_field(locator, find_options).execute_script %Q(this.value = "#{to}") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment