Skip to content

Instantly share code, notes, and snippets.

@glaszig
Created October 15, 2018 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glaszig/edef1f58ca62f1e58c724ad221563579 to your computer and use it in GitHub Desktop.
Save glaszig/edef1f58ca62f1e58c724ad221563579 to your computer and use it in GitHub Desktop.
Method to set value of range input field with Capybara
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