[Wtr-development] [JIRA] Commented: (WTR-457) FileField.set("<file_path>") hangs inconsistently and not guranteed to work all the time, better workaround/fix included here

Jason McInerney (JIRA) watirjira at gmail.com
Tue Oct 12 12:23:19 EDT 2010

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

Jason McInerney commented on WTR-457:

I have this issue with 1.6.5 on IE6, Windows XP

Interestingly, the first time a test uses this, it hangs. 
Then every test afterward works fine. 

I will add more to comment if I can find anything else. 

> 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


More information about the Wtr-development mailing list