我正在尝试在定义为表的日期选择器中选择多个项目,在 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(多月)/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'
有人可以在他的代码中使用它吗?或者有没有人将修改器发送到鼠标事件的解决方案?提前致谢。