如何使用属性值查找文本(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)

I'm not quite sure what the issue is with my code, obviously I've gone wrong somewhere. Here's the code;

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

And here's the error;

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

最满意答案

autoassign属于String类型。 Ruby String类没有名为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') }

autoassign is of type String. Ruby String class has no method named attribute_value.

Try removing .html from the first line so it looks likes this:

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') }如何使用属性值查找文本(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)

I'm not quite sure what the issue is with my code, obviously I've gone wrong somewhere. Here's the code;

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

And here's the error;

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

最满意答案

autoassign属于String类型。 Ruby String类没有名为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') }

autoassign is of type String. Ruby String class has no method named attribute_value.

Try removing .html from the first line so it looks likes this:

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') }