Skip to content

Instantly share code, notes, and snippets.

@peteryates
Last active February 8, 2019 10:05
Show Gist options
  • Save peteryates/bb568d2f3436294d5a5c10025a759fc1 to your computer and use it in GitHub Desktop.
Save peteryates/bb568d2f3436294d5a5c10025a759fc1 to your computer and use it in GitHub Desktop.
Interacting with checkboxes and radio buttons
Given("I am on the {string} page") do |string|
path_for(string).tap do |p|
visit(p)
expect(page.current_path).to eql(p)
end
make_inputs_opaque if opaquify_inputs?
end
def opaquify_inputs?
page.driver.is_a?(Capybara::Selenium::Driver)
end
def make_inputs_opaque
script = <<~SCRIPT
document
.querySelectorAll("input[type='checkbox'], input[type='radio']")
.forEach(
function(element) {element.setAttribute("style", "opacity: 1;")}
);
SCRIPT
page.execute_script(script)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment