浏览了很多问题和论坛,但我无法弄清楚。Watir 很新鲜。
在用户可以创建组的网页上进行测试(该解决方案构建在 kendoui 框架内)
创建一个组。
browser.button(:id => "add_group").click
browser.text_field(:id => "group_name").set("delete")
browser.button(:id => "add_group").click
创建了组,然后我想删除该组。如果用户将鼠标悬停在新组上,则会在组容器的右侧出现一个 thrashcan 符号,然后单击该组会被删除。
代码:
<div id="left_pane" class="side_panel k-pane k-scrollable" style="position: absolute; top: 0px; width: 220px; height: 724px; left: 0px;">
<ul id="toolbox_panel" class="k-widget k-reset k-header k-panelbar" data-role="panelbar">
<li class="k-item k-state-default k-first">
<li id="group_ungrouped" class="k-item k-state-default" data-role="droptarget">
<li id="group_delete" class="k-item k-state-default k-last" data-role="droptarget">
<span class="k-link k-header k-state-hover">delete</span>
<!--snipp below is only visible on hover of delete element-->
delete
<span class="minicon remove_pod"></span>
</li>
我用 Watir 尝试过的几件事:
browser.div(:id, 'left_pane').ul(:id, 'toolbox_panel').li(:id, 'group_delete').span(:class, 'minicon remove_pod').fire_event "onclick"
给出以下内容:
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.1/lib/watir-webdriver/elements/element.rb:36 5:in
assert_exists': unable to locate element, using {:class=>"minicon remove_pod", :tag_name=>"spa n"} (Watir::Exception::UnknownObjectException) from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.1/lib/watir-webdriver/elements/ element.rb:247:in
fire_event' 来自 C:/bin/scripts /ruby/sm_groups.rb:34:in `'
其他测试:
browser.div(:id, 'left_pane').ul(:id, 'toolbox_panel').li(:id, 'group_delete').span(:class, /k-state-hover/).span(:class , 'minicon remove_pod').fire_event "onclick"
browser.div(:id, 'left_pane').ul(:id, 'toolbox_panel').li(:id, 'group_delete').span(:class, 'k-link k-header k-state-hover' ).span(:class, 'minicon remove_pod').click
我对如何悬停“group_delete”然后在悬停时找到delete/minicon remove_pod并单击它以删除创建的内容有点不知所措。
如果需要更多信息,请告诉我。
此致