如何使用属性值查找文本

时间:2015-11-06 16:02:09

标签: ruby selenium cucumber watir rubymine

我不太确定我的代码是什么问题,显然我在某个地方出了问题。这是代码;

Then(/^the room selection should be switched to auto assign$/) do
  autoassign = @browser.iframe(:id , 'iconsole-plugin-session_iframe__').div(:class , 'col-md-8 column').span(:id , 'selected_room').html
  Watir::Wait.for_condition(10 , 2 , "Waiting for room to auto assign") {
    autoassign.attribute_value(:id).eql?('Auto Assignment')
  }
end

这是错误;

undefined method `attribute_value' for "<span id=\"selected_room\">Auto Assignment</span>":String (NoMethodError)

1 个答案:

答案 0 :(得分:0)

autoassign的类型为StringRuby String class没有名为attribute_value的方法。

尝试从第一行删除.html,使其看起来像这样:

autoassign = @browser.iframe(:id , 'iconsole-plugin-session_iframe__').div(:class , 'col-md-8 column').span(:id , 'selected_room')
Watir::Wait.for_condition(10 , 2 , "Waiting for room to auto assign") {
autoassign.attribute_value(:id).eql?('Auto Assignment')
}