FireWatir TextField 设置:非常慢
当在 ruby 中调用 text_field 的 set
方法时,在浏览器中输入文本的速度非常慢,大约为 1 个字符/秒。
环境信息:
- Ubuntu 10.10
- FireFox 3.6.13
- JSSh 0.9
- Ruby 1.9.2p136
- FireWatir 1.7.1
请建议。提前致谢。
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:
- Ubuntu 10.10
- FireFox 3.6.13
- JSSh 0.9
- Ruby 1.9.2p136
- FireWatir 1.7.1
Kindly advice. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(2)
Spring初心2024-10-24 13:35:59
解决 firewatir 上按键输入速度慢的问题:
需要编辑文件 text_field.rb
进入文件夹
#>cd /usr/lib/ruby/gems/1.8/gems/firewatir-1.7.1/lib/firewatir/elements/
使其可写#>chmod第777
- 章.fireEvent("onKeyPress") 和
@o.fireEvent("onKeyPress")
改为输入 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
现在它应该工作得更快
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
这是一个已知错误: WTR-397
解决方法是使用 watir-webdriver 或使用
value=
而不是设置。例子:
It is a known bug: WTR-397
Workaround is to use watir-webdriver or to use
value=
instead ofset
. Example: