I have a file field that has opacity: 0
and is overlaping a fake button. Its a common css technic to fake a sort of \"Upload button\" that displays consistently acr
In general interacting with non-visible elements should not be possible when using Capybara (you can find them using the visible: false/hidden
option in most finders but not actually do anything to them). However, the file input is a special case because of how common it is to hide the element and, due to security restrictions, no other way to actually add a file by interacting with the pages visible elements. Because of this attach_file
has a make_visible
option which can be used to have Capybara make the element visible, attach the file, and then reset the CSS to the original setting.
attach_file('photos', file_path, make_visible: true)