Last active
January 29, 2021 02:10
-
-
Save vumanhcuongit/4df16452d88fda4c05bf to your computer and use it in GitHub Desktop.
Drag & Drop Cucumber
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
When /^I drag the file "([^\"]*)" to "([^\"]*)"$/ do |file, field| | |
# make an input field be visible | |
page.execute_script("document.getElementsByName('#{field}')[0].className = '';") # remove class .hidden | |
page.execute_script("document.getElementsByName('#{field}')[0].setAttribute('style', 'display:block;')") # remove style="display: none;" | |
patiently do | |
attach_file(field, File.expand_path(file)) # attach file to input | |
end | |
draggable = page.find(".topMenu") # whatever | |
droppable = page.find("##{field}") # an input where we'll drag file into | |
draggable.drag_to(droppable) # f*cking awesome | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment