Yes, the problem is (:value, ‘Value’) in this line: 

ie.file_field(:value,'Value').set(#{path})

 

The file_field supports these attributes:  :id, :name, :index.  Do a view source and find out what the attribute values for your <input type = file> tag.  If for some reason your developers were lazy and didn’t give the tag an id or name attribute, use index.  If there are more than one <input type = file> tag on the page the indexing starts top-most down with 1 and increments from there. 

 

Here is the usage portion for file_field from Watir.rb:

        # This is the main method for accessing a file field. Usually an <input type = file> HTML tag. 

        #  *  how   - symbol - how we access the field , :index, :id, :name etc

        #  *  what  - string, int or re , what we are looking for,

        #

        # returns a FileField object

        #

        # Typical Usage

        #

        #    ie.file_field(:id,   'up_1')                     # access the file upload field with an ID of up_1

        #    ie.file_field(:name, 'upload')               # access the file upload field with a name of upload

        #    ie.file_field(:index, 2)                         # access the second file upload on the page ( 1 based, so the first field is accessed with :index,1)

 

Hope this helps,

 

--Mark

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of chaya shetty
Sent: Thursday, January 05, 2006 4:45 AM
To: [email protected]
Subject: Re: [Wtr-general] How can I open and attach file using file_fieldmethod?

 

Hi,

    I  tried with  
    path = "C\:Watir\Text.doc"


    ie.file_field(:value,'Value').set(#{path})
 

    $autoit = WIN32OLE.new("AutoItX3.Control") 

   $autoit.WinActivate("Choose file")

   $autoit.ControlSetText("Choose file", "", "Edit1", "#{path}") 

   $autoit.ControlClick("Choose file", "Look &in", "&Open")    

    $ie.button(:name, "Submit").click

 

But the same behaviour persists. 

i.e. the "Choose File" window opens and waits till you manually select the file.

 

Can't  ie.file_field(:value,'Value').set(#{path}) automatically set the path?

 

Thanks

Chaya

 



 



--Mark


Amitha Shetty <[EMAIL PROTECTED]> wrote:

Hi,

How can I open and attach file using file_field method?

when I try,

ie.file_field(:id,'uploaded_file').set('C:\file.txt')

I get "choose file"-window open .It waits for me, to choose a file and 
click "open" or whatever the button is called) , after that it 
continues normally, by submitting the file_field content. Why doesn't he choose a file by himself?How do I handle this?

I have ensured that there is no space in the path and the file exists in C: )
I get the same error when I run filefield_test in Unittests in watir folder.

 

Thanks,

Amitha

 

Send instant messages to your online friends http://in.messenger.yahoo.com _______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

 

Send instant messages to your online friends http://in.messenger.yahoo.com

_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to