Last active
February 8, 2019 10:05
-
-
Save peteryates/bb568d2f3436294d5a5c10025a759fc1 to your computer and use it in GitHub Desktop.
Interacting with checkboxes and radio buttons
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
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 |
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
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