“类型错误:无法将字符串转换为整数”当尝试 CTRL 单击或 SHIFT 单击 watir-webdriver/selenium-webdriver 脚本时
我正在尝试在 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'
有人能够在他的代码中使用它吗? 或者有人有向鼠标事件发送修饰符的解决方案吗? 提前致谢。
I am trying to select multiple items in a date picker defined as table, in a cucumber script using watir-webdriver/selenium-webdriver on Chrome browser.
The date picker allows Ctrl and Shift as modifiers.
This is the code for a cell:
<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>
And this is a sample to what the datepicker is behaving -
http://demo.essentialobjects.com/Demos/Calendar/Designs/Windows%20(Multi-Month)/Demo.aspx
I have tried to use:
driver.action.key_down(:shift).
click(element).
click(second_element).
perform
but I get "TypeError: can't convert String into Integer".
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'
Was anyone able to use this in his code?
Or has anyone a solution for sending modifiers to mouse events?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
关于 Watir-Webdriver,我向 Jari(Watir-webdriver 背后的主要驱动力)询问了这个问题,得到了以下答案,如果你非常需要这个,这可能会给你一条追求的道路
我还创建了一个功能请求 Github 上的 Watir-Webdriver 项目,如果这是您需要的东西,您可能需要对其进行评论以表明您的需求。
With regard to Watir-Webdriver I asked Jari (the main driving force behind Watir-webdriver) about this and got the following answer, which may give you a path to pursue if you need this badly enough
I also created a feature-request in the Watir-Webdriver project on Github, if this is something you need, you may want to comment on it to make your needs known.
这将从页面上的第三个日历中选择2009年12月1-6日:
我没有注意到日历响应shift或ctrl(手动)。第一次单击将选择开始日期,第二次单击将选择结束日期。
This will select December 1-6 2009 from the third calendar on the page:
I did not notice that calendar responds to shift or ctrl (manually). The first click will select start date, the second one end date.
我没有注意到日历响应 Shift 或 Ctrl(手动)。您可以通过单击日期来选择最多 5 天。如果您选择第六个,则您选择的第一个将自动取消选择。
这将选择 2011 年 11 月 1 日和 3 日:
I did not notice that calendar responds to shift or ctrl (manually). You can select up to 5 days by clicking the day. If you select sixth, the first one that you have selected will automatically be unselected.
This will select November 1 and 3 2011: