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

Mark Wieder commented on WTR-465:
---------------------------------

Is there a downside to this? Here's the original from htmlelements.rb

for i in 0..value.length-1
    #sleep element.typingspeed   # typing speed
    c = value[i,1]
    #element.log  " adding c.chr " + c  #.chr.to_s
    @o.value = "#{(@o.value.to_s + c)}"   #c.chr
    @o.fireEvent("onKeyDown")
    @o.fireEvent("onKeyPress")
    @o.fireEvent("onKeyUp")
end

causing a read of the textfield for each string char entered. This seems 
unnecessary except for the case where you really *do* want to slow down text 
input, and for that you'd use individual doKeyPress operations with sleeps 
interspersed. What I've done is eliminate the for loop and its associated 
reread of the text field and simply catenate the string all at once. Works for 
me and I don't see any drawbacks.


> improved speed of filling text fields
> -------------------------------------
>
>                 Key: WTR-465
>                 URL: http://jira.openqa.org/browse/WTR-465
>             Project: Watir
>          Issue Type: Improvement
>          Components: FireWatir
>    Affects Versions: 1.6.7
>         Environment: Fedora Core 13, Firefox 3.6.12
>            Reporter: Mark Wieder
>            Assignee: Angrez
>
> The set method for filling text fields was operating at about one char per 
> second, so I rewrote doKeyPress. It now works much faster for both append and 
> set.
>       begin
>         #...existing test for max length
>       end
>       # get existing text
>       oldvalue = "#{(o.value.to_s)}"
>       # append new text
>       oldvalue += value
>       @o.value = oldvalue
>       @o.fireEvent("onKeyDown")
>       @o.fireEvent("onKeyPress")
>       @o.fireEvent("onKeyUp")
> Tried and failed to create a diff file for you...

-- 
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
Wtr-development@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-development

Reply via email to