Remove file catcher event listener once file element is determined

This commit is contained in:
Thomas Walpole 2019-05-09 12:24:43 -07:00
parent 6335d16e15
commit 533f1be2ed
2 changed files with 2 additions and 3 deletions

View File

@ -393,9 +393,10 @@ module Capybara
JS
CAPTURE_FILE_ELEMENT_SCRIPT = <<~'JS'
document.addEventListener('click', function(e){
document.addEventListener('click', function file_catcher(e){
if (e.target.matches("input[type='file']")) {
window._capybara_clicked_file_input = e.target;
this.removeEventListener('click', file_catcher);
e.preventDefault();
}
})

View File

@ -54,8 +54,6 @@ Capybara::SpecHelper.run_specs TestSessions::Safari, SAFARI_DRIVER.to_s, capybar
pending 'safaridriver thinks these links are non-interactable for some unknown reason'
when /Capybara::Session selenium_safari #attach_file with a block can upload by clicking the file input/
skip "safaridriver doesn't allow clicking on file inputs"
when /Capybara::Session selenium_safari #attach_file with a block can upload by clicking the label/
skip 'hangs tests'
when /Capybara::Session selenium_safari #within_frame works if the frame is closed/,
/Capybara::Session selenium_safari #switch_to_frame works if the frame is closed/
skip 'Safari has a race condition when clicking an element that causes the frame to close. It will sometimes raise a NoSuchFrameError'