FireWatir TextField set : Very Slow

荒凉一梦 提交于 2020-01-30 06:40:05

问题


When calling the set method of a text_field in ruby, the text is being entered at a very slow rate in the browser, roughly at 1 character / second.

Environment Information:

  1. Ubuntu 10.10
  2. FireFox 3.6.13
  3. JSSh 0.9
  4. Ruby 1.9.2p136
  5. FireWatir 1.7.1

Kindly advice. Thanks in advance.


回答1:


It is a known bug: WTR-397

Workaround is to use watir-webdriver or to use value= instead of set. Example:

browser.text_field(how => what).value= "string"



回答2:


solve slow key type issue on firewatir:

need to edit the file text_field.rb enter to the folder

  1. #>cd /usr/lib/ruby/gems/1.8/gems/firewatir-1.7.1/lib/firewatir/elements/ make it writeable
  2. #>chmod 777 text_field.rb edit the proc def doKeyPress( value )
  3. put # in front of @o.fireEvent("onKeyDown") and @o.fireEvent("onKeyPress") and @o.fireEvent("onKeyPress")

instead enter fire_key_events

 def doKeyPress( value )
      begin
        max = maxlength
        if (max > 0 && value.length > max)
          original_value = value
          value = original_value[0...max]
          element.log " Supplied string is #{suppliedValue.length} chars, which exceeds the max length (#{max}) of the field. Using value: #{value}"
        end
      rescue
        # probably a text area - so it doesnt have a max Length
      end
      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
    fire_key_events #add this
        #@o.fireEvent("onKeyDown")
        #@o.fireEvent("onKeyPress")
        #@o.fireEvent("onKeyUp")
      end

now it should work faster



来源:https://stackoverflow.com/questions/5000164/firewatir-textfield-set-very-slow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!