[ 
http://jira.openqa.org/browse/WTR-457?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=19901#action_19901
 ] 

Ethan commented on WTR-457:
---------------------------

It certainly needs a rewrite. You might take a look at vapir's implementation, 
using WinWindow library. 

http://github.com/vapir/vapir/blob/vapir-1.7.1/vapir-ie/lib/vapir-ie/input_elements.rb#L107

http://github.com/vapir/vapir/blob/vapir-1.7.1/vapir-ie/lib/vapir-ie/scripts/select_file.rb#L1


> FileField.set("<file_path>") hangs inconsistently and not guranteed to work 
> all the time, better workaround/fix included here
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: WTR-457
>                 URL: http://jira.openqa.org/browse/WTR-457
>             Project: Watir
>          Issue Type: Improvement
>          Components: Inputs
>    Affects Versions: 1.6.2, 1.6.5
>         Environment: Windows XP SP2, (Ruby 1.8.26, Watir 1.6.2) OR (Ruby 
> 1.8.7-p299, Watir 1.6.5)
>            Reporter: Yogesh Prajapati
>            Assignee: Jarmo Pertman
>            Priority: Blocker
>         Attachments: input_elements.rb
>
>
> When trying trying to upload a file using file input field, I am using the 
> WATIR api $ie.file_field(:id, "fileupload").set("#{aFileName.to_s}"), the 
> sometimes IE seemed to open "file open" dialog, it will set the file path 
> correctly and close the "file open" dialog box fine and the file input field 
> get populated correctly with expected file path, but majority of the times 
> the dialog box will stay open (hanging) and no file name/path set in "File 
> Name" edit field and nothing happens there after.
> I kind of played around changing sleep time in 
> "input_elements.rb:FileField.set()" method to make it work. What I noticed 
> that higher sleeping time made the problem worse.
> By understanding little bit more about what the "set()" is trying to do, it 
> seemed like a callback method (after file open dialog box pops up). So as it 
> says on the line for sleep commands, "it takes some time for popup to 
> appear", it sounded like that it is too early to make a sleep call i.e. 
> before launching a separate new process to set the file location in dialog. 
> It is apparent that the wait (sleep) should rather be done within the new 
> process launched by making 'system' call instead of putting the enclosing 
> thread to wait even before starting the new process. 
> Having said that, by putting the thread to wait before launching new process, 
> file open dialog box pops up and entire ruby process waits for manually input 
> (to me it meant broken automated workflow) and that's not acceptable.
> So the fix to issue of hanging file open dialog box move line "sleep 1..." 
> withing system call (i.e. "system %{ruby -e '...." ) just below line 'require 
> "win32ole"' and may be increase sleep time to 2 or 4 seconds depending up 
> fast or slow machine.
> The fix for me with 4 seconds sleep time worked equally good on both slow 
> (Pentium4, WinXP SP2) and fast (Core2Duo, WinXP SP2) machines. Please find 
> the updated "input_elements.rb" attached here.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.openqa.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

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

Reply via email to