12.01.06

Faster FileField#set

Posted in Watir at 4:41 pm by Željko Filipin

This is slightly edited conversation Is there a way to make file_field.set faster? from wtr-general mailing list.

Me:

Is there a way to make file_field.set faster?

I have noticed that this is the slowest part of my tests. It takes about 10 seconds to set file field. I have read that it can not be set directly because that would be security issue, but I wonder what I could do to make it faster. I upload extremely small files (a few bytes), but I have to do it frequently, and every time it takes about 10 seconds just to set file field.

Mark Cain:

This works for me and it is much faster because it uses the handle of the object.

Me:

startClicker works double faster than file_field.set.

Then I removed line with “sleep 3″.

Me:

It is now even faster (for three seconds) after I removed line with “sleep 3″ (when I noticed that comment says that it can be removed) .

file_field.set needed approximately 10,6 seconds to set file field, startClicker 4,4, and when I removed “sleep 3″, it is down to 1,4. That saved me approximately 9 seconds for each file upload (and I do it a lot).

Paul Rogers also suggested AutoIt, but this works fast enough, so I did not even try it.

Leave a Comment