I am looking at a web page with an overlay that contains a Choose File/Browse etc button
Below is a snippet from the page
<form name = "form1" method = "post" action = "UploadPhoto.aspx?PhotoUploaderFor=1" id = "form1" enctype = "multipart/form-data">
<div>...</div>
<div class = "popup-form photoUploader">
<div class = "group data-row">
<label>...</label>
<input type ="file" name = "FileUpload1" id = "FileUpload1" class = "browse_file">
Watir has file_fields which can handle file uploads
I’ve tried on the test site (www.tinypic.com) and the controls work fine there
b.file_fields.exists?
will return true
However, on the page i’m looking at with the snippet above,
b.file_fields.exists?
returns false
I thought it might be because of the form, so I also tried
b.form(:name => "form1").file_fields.exists?
Which also returns false
If i try to access the button itself directly, this also returns false
b.element(:xpath => "//input [@name = 'FileUpload1']").exists?
Anyone have any ideas?
EDIT
The form is inside an iframe
<iframe id="Step1_Banner1_Popup_Photo_Photo_Iframe_PhotoUploader" class="photoUploaderFrame" scrolling="no" src="../MSReport3/UserControls/UploadPhoto.aspx?PhotoUploaderFor=1">
#document
<!DOCTYPE html PUBLIC "-//W3C//DTD CHTML 1.0 .....">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>...</head>
<body>
<code from above goes here>
NOTE: I’m posting the solution from the comments so that (hopefully) this question can be tagged as answered.
The overlay is within a frame, and it’s necessary to specify the frame via method-chaining. For example: