【发布时间】:2013-03-12 20:18:50
【问题描述】:
我正在使用 Ruby 1.8.7、Watir-Webdriver 0.6.1、Arch Linux、Firefox 14
我已经阅读了很多关于这个主题的答案和示例,但没有一个对我有用。 当我想将一大段数据(只有大约 15 行文本)粘贴到 textarea 中时,速度非常慢。因为我不想输入仿真,所以我想要最大可用速度,所以我尝试设置变量“browser.speed = :zippy”,但它似乎在 Watir-Webdriver 中不起作用,只出现一条错误消息: "# 的未定义方法 `speed='"
然后我尝试将native_events设置为false,再次出现错误消息: “用于 # 的未定义方法 `native_events'” 所以我有点困惑。
这是我的全部代码sn-p
require 'rubygems'
require 'watir-webdriver'
require 'xmlsimple'
default_profile = Selenium::WebDriver::Firefox::Profile.from_name "default"
default_profile.native_events = false
default_profile['javascript.enabled']=false
browser = Watir::Browser.new :ff, :profile => default_profile
browser.speed = :zippy
第 5 行、第 6 行和第 8 行都抛出错误消息。
最后我尝试编辑 text_field.rb,因为它在这个答案 (http://stackoverflow.com/questions/5000164/firewatir-textfield-set-very-slow) 中提到,但它在一个 .gem 文件中并在 tar.gz 中。我解压了,但找不到相关行:
# encoding: utf-8
module Watir
class TextField < Input
include UserEditable
attributes Watir::TextArea.typed_attributes
remove_method :type # we want Input#type here, which was overriden by TextArea's attributes
private
def locator_class
TextFieldLocator
end
def selector_string
selector = @selector.dup
selector[:type] = '(any text type)'
selector[:tag_name] = "input or textarea"
selector.inspect
end
end
module Container
def text_field(*args)
TextField.new(self, extract_selector(args).merge(:tag_name => "input"))
end
def text_fields(*args)
TextFieldCollection.new(self, extract_selector(args).merge(:tag_name => "input"))
end
end # Container
class TextFieldCollection < InputCollection
private
def locator_class
TextFieldLocator
end
def element_class
TextField
end
end # TextFieldCollection
end
【问题讨论】:
标签: performance firefox selenium webdriver watir