It looks like you are using SWFUpload a flash based utility that
allows for some special upload capabilities (set the file extensions,
multiple files, etc) This means it's using non standard upload
controls.
You MIGHT be able to work around it by overriding the hidden values,
but the other option would be to automate at the UI level. I can't
say what would work best for this on a Mac, but on the Windows side,
the RAutomation gem makes pretty short work of that upload window.
require 'rautomation'
$browser.div(:id, 'theme_uploader').object.click #this
'object' is the SWFUpload flash 'search' button that launches the
SFWUpload 'select file(s) to upload...' window
window = RAutomation::Window.new :title => /Select file/
window.text_field(:class => "Edit").set('C:\sandbox\QAAuto\Image
\Image\spicy_728x90.gif')
window.button(:value => "&Open").click
On Oct 18, 7:22 am, Joe Fleck <[email protected]> wrote:
> Hi Jari,
>
> Here is the HTML code. Will this help?
>
> <legend>Video Attachment Details</legend>
> <div id="add-video" class="add-video">
> <input id="video_attachment_video_file_name" type="hidden" name="
> video_attachment[video_file_name]">
> <label for="video_attachment_video_file_name">
> <input id="video_filename" class="video-upload file" type="text" disabled="
> disabled">
> <object id="SWFUpload_0" class="swfupload" width="87" height="27" data="
>
> I am not sure what you mean by [The only way to deal with these types of
> uploads is to make the file field visible, usually by modifying its style
> through Browser#execute_script.]. Can you give me an example?
>
> Thank you,
> Joe
>
>
>
>
>
>
>
> On Tue, Oct 18, 2011 at 10:35 AM, Jari Bakken <[email protected]> wrote:
> > Some file upload solutions lets the user click a link, which then creates a
> > hidden file field and opens the upload dialog. The only way to deal with
> > these types of uploads is to make the file field visible, usually by
> > modifying its style through Browser#execute_script. This may be what you're
> > seeing, though unless you show us a page that will reproduce the problem,
> > it's a wild guess.
>
> > Jari
>
> > On Tue, Oct 18, 2011 at 4:19 PM, Joe Fleck <[email protected]> wrote:
>
> >> Hi,
>
> >> Thank you all for helping. I really appreciate it.
>
> >> I believe the file path is correct now because the error message I am now
> >> getting has changed.
>
> >> Code:
> >> #Attach file
> >> @browser.file_field(:id,
> >> "the_file").set("/Users/josephfleck/Documents/DownloadDocs/DataFile.xls")
>
> >> It doesn't object name i am giving it. Do I need to use something else
> >> like the actual object name of the text field?
>
> >> /Users/josephfleck/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/gems/1.8/gems/watir-webdriver-0.3.4/lib/watir-webdriver/elements/element.rb:248:in
> >> `assert_exists': unable to locate element, using {:type=>"file",
> >> :tag_name=>"input", :id=>"the_file"}
> >> (Watir::Exception::UnknownObjectException)
> >> from
> >> /Users/josephfleck/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/gems/1.8/gems/watir-webdriver-0.3.4/lib/watir-webdriver/elements/file_field.rb:23:in
> >> `value='
> >> from
> >> /Users/josephfleck/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/gems/1.8/gems/watir-webdriver-0.3.4/lib/watir-webdriver/elements/file_field.rb:14:in
> >> `set'
> >> from ./common/helper_methods.rb:182:in `share_documents'
> >> from
> >> /Users/josephfleck/Sites/within3/qa_automation/discussion/add_multiple_discussion.rb:159
> >> from
> >> /Users/josephfleck/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/gems/1.8/gems/fastercsv-1.5.4/lib/faster_csv.rb:696:in
> >> `each'
> >> from
> >> /Users/josephfleck/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/gems/1.8/gems/fastercsv-1.5.4/lib/faster_csv.rb:696:in
> >> `each'
> >> from
> >> /Users/josephfleck/Sites/within3/qa_automation/discussion/add_multiple_discussion.rb:38
>
> >> On Tue, Oct 18, 2011 at 9:28 AM, Joe DiMauro <[email protected]> wrote:
>
> >>> Another thing I noticed. Due to the path ending with
> >>> \criptDataFile.xls
>
> >>> It appers that the backslash followed by the two characters "cr"
> >>> is being interpeted as a Carridge Return. You can see this
> >>> in the error message:
>
> >>> No such file or directory - Users/josephfleck/Documents/Download
> >>> Docs/ iptDataFile.xls (Errno::ENOENT)
> >>> ^
> >>> Notice the space instead of the characters"cr" indicating
> >>> that \cr was interpreted as a Carriage Return, not the first
> >>> two characters in the file name "criptDataFile.xls"
>
> >>> So try all these:
> >>> 1. Use a full pathname, not a relative path (as previously mentioned)
> >>> Unless Ruby is running with the Root level of your Mac as it
> >>> working
> >>> directory, (which I'm pretty sure its not), then the Users
> >>> directory will not be a valid relative path.)
>
> >>> 2. Remove the backslashes. They are not necessary on Mac/Linus OS,
> >>> (as previously mentioned), and may cause issues (e.g. \cr)
>
> >>> 3. Always a good idea (as previously mentioned), to upgrade to the
> >>> latest version of the gems, (and Ruby if possible)
>
> >>> If you are also running safariWatir you may not be able to upgrade
> >>> to Ruby 1.9.x. I don't recall if safariWatir supports 1.9.x yet.
>
> >>> 4. The space in the directory name should not be an issue, since the
> >>> full path is quoted, but whenever possible using directory
> >>> and file names without spaces is always safer.
>
> >>> Joe DiMauro
>
> >>> On Oct 17, 4:42 pm, Chuck van der Linden <[email protected]> wrote:
> >>> > or escape the space with a backslash? same as you are doing for the
> >>> > slashes? (but Michael's solution of using double-quotes might be even
> >>> > easier)
>
> >>> > On Oct 17, 1:50 pm, Željko Filipin <[email protected]>
> >>> > wrote:
>
> >>> > > On Mon, Oct 17, 2011 at 10:01 PM, Joe Fleck <[email protected]>
> >>> wrote:
> >>> > > > No such file or directory - Users/josephfleck/Documents/Download
> >>> Docs/
>
> >>> > > iptDataFile.xls
>
> >>> > > Try putting the file in a folder that has no spaces, something
> >>> > > like Users/josephfleck
>
> >>> > > Željko
>
> >>> --
> >>> Before posting, please readhttp://watir.com/support. In short: search
> >>> before you ask, be nice.
>
> >>> [email protected]
> >>>http://groups.google.com/group/watir-general
> >>> [email protected]<http://groups.google.com/group/watir-generalwatir-general+unsubscribe...>
>
> >> --
> >> Before posting, please readhttp://watir.com/support. In short: search
> >> before you ask, be nice.
>
> >> [email protected]
> >>http://groups.google.com/group/watir-general
> >> [email protected]
>
> > --
> > Before posting, please readhttp://watir.com/support. In short: search
> > before you ask, be nice.
>
> > [email protected]
> >http://groups.google.com/group/watir-general
> > [email protected]
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
[email protected]
http://groups.google.com/group/watir-general
[email protected]