如何使用属性值查找文本

How to find text using attribute value

我不太确定我的代码有什么问题,显然我哪里出错了。这是代码;

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)

autoassignString 类型。 Ruby 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')
}