ruby - 尝试在watir-webdriver / selenium-webdriver脚本中按CTRL +单击或SHIFT +单击时出现“ TypeError:无法将字符串转换为整数”

我试图在一个定义为table的日期选择器中选择多个项目,在cucumber脚本中使用chrome浏览器上的watir webdriver/selenium webdriver。
日期选择器允许ctrl和shift作为修饰符。
这是单元格的代码:

<div type="button" class="datepicker_day" onclick="if(!ample.$instance(this).$isAccessible()) return; DatePicker.onSelectDay(ample.$instance(this), '2011/06/03')" onmouseover="if(!ample.$instance(this).$isAccessible()) return;if (!this.className.match(/_day-disabled/)) this.className += 'datepicker_day-hover'" onmouseout="if(!ample.$instance(this).$isAccessible()) return; if (!this.className.match(/_day-disabled/)) this.className = this.className.replace('datepicker_day-hover', '')">3</div>

这是一个日期选择器行为的示例-
http://demo.essentialobjects.com/Demos/Calendar/Designs/Windows%20(Multi-Month)/Demo.aspx
我试图使用:
driver.action.key_down(:shift).
click(element).
click(second_element).
perform

但我得到“typeerror:无法将字符串转换为整数”。
from C:/Ruby/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.9.1/lib/selenium/webdriver/remote/response.rb:59:in `[]'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.9.1/lib/selenium/webdriver/remote/response.rb:59:in `add_backtrace'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.9.1/lib/selenium/webdriver/remote/response.rb:23:in `error'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.9.1/lib/selenium/webdriver/remote/response.rb:50:in `assert_ok'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.9.1/lib/selenium/webdriver/remote/response.rb:15:in `initialize'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.9.1/lib/selenium/webdriver/remote/http/common.rb:54:in `new'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.9.1/lib/selenium/webdriver/remote/http/common.rb:54:in `create_response'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.9.1/lib/selenium/webdriver/remote/http/default.rb:64:in `request'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.9.1/lib/selenium/webdriver/remote/http/common.rb:35:in `call'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.9.1/lib/selenium/webdriver/remote/bridge.rb:430:in `raw_execute'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.9.1/lib/selenium/webdriver/remote/bridge.rb:408:in `execute'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.9.1/lib/selenium/webdriver/remote/bridge.rb:274:in `sendModifierKeyToActiveElement'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.9.1/lib/selenium/webdriver/common/keyboard.rb:26:in `press'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.9.1/lib/selenium/webdriver/common/action_builder.rb:122:in `block in perform'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.9.1/lib/selenium/webdriver/common/action_builder.rb:121:in `each'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.9.1/lib/selenium/webdriver/common/action_builder.rb:121:in `perform'

有人能在他的代码中使用这个吗?
或者有谁能解决向鼠标事件发送修饰符的问题?
提前谢谢。

最佳答案

关于watir webdriver,我问了jari(watir webdriver背后的主要驱动力)这个问题,得到了以下答案,如果你非常需要这个,这可能会给你一条追求的道路
watir webdriver中还没有公开任何内容,但您应该
可以使用webdriver中的actions api来实现(请参见
http://rubydoc.info/gems/selenium-webdriver/2.10.0/Selenium/WebDriver/ActionBuilder
我不确定这在浏览器中有多好的支持,但是从
Java测试(它是最广泛的)看起来像是当前的
仅在Firefox+Linux上受支持:
http://code.google.com/p/selenium/source/browse/trunk/java/client/test/org/openqa/selenium/interactions/CombinedInputActionsTest.java#50
我还在github上的watir webdriver项目中创建了一个feature-request,如果这是您需要的东西,您可能需要对它进行评论,以使您的需要为人所知。

本文翻译自 https://stackoverflow.com/questions/7865263/

网站遵循 CC BY-SA 4.0 协议,转载或引用请注明出处。

标签 ruby selenium-webdriver watir-webdriver modifiers


相关文章:

ruby - watir打印/放置所有可见链接

ruby - Ruby为国际象棋网格命名Square对象

ruby-on-rails - 无法使用Mongoid和Geocoder对嵌入式文档进行地理查询

ruby - 为什么不能使用新的Ruby 1.9.2哈希语法将整数用作键?

node.js - 我们如何停止webdriver-manager?

ruby - 如何使用带有特定标签的parallel_tests

javascript - 在watir-webdriver中运行JavaScript

ruby - 如何构建一个正则表达式来删除字符,后跟退格键

python - 在代理服务器后面运行selenium

python - 如何检查硒(python 2)中是否存在某个元素而没有抛出NoSuchElement异常呢?