the html like this
<input type='file' id='ok' class='lalalalala'>
my code is attach_file("ok","./fileset/publisher/upload_pic.jpg") but I got fail: Failures:
Capybara::ElementNotFound:
Unable to find file field "ok"
so what is file field? how can I upload file?
From the Capybara docs:
The file field can be found via its name, id or label text.
And you clearly have this already, which is a bit puzzling. Is there a modal window blocking this and/or is the page.driver switched to something else by chance? I ask because it's actually not completely necessary to interact with a form button and cause a modal or file/Explorer/Finder window to appear, and sometimes this can confuse the page.driver (ex: switches focus to the window instead of the page).
Try removing any click_button actions just prior to this step, and then try this:
attach_file('ok', File.absolute_path('./fileset/publisher/upload_pic.jpg'))
This has worked for me previously, in a super deeply parented div which ended up with a button class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With