5

次のような画像があると想像してください。

the_image = @browser.image(:id, 'image01')

そのクラスの値を取得する方法は次のとおりです。

image_status = the_image.attribute_value('class')

Ok。私は page_object gem を使用しており、次のように画像を要素として持っているとします。

image(:the_image, :id => 'image01')

attribute_value を取得するには、次を使用できます。

image_status = the_image_element.attribute_value('class')

...しかし、非推奨の警告が表示されます:

*** DEPRECATION WARNING
*** You are calling a method named attribute_value at page.rb:68:in `get_status'.
*** This method does not exist in page-object so it is being passed to the driver.
*** This feature will be removed in the near future.

classpage_object 要素を使用して値を取得するにはどうすればよいですか? 確かに答えは簡単ですが、私はそれを見つけられませんでした。道を教えてください。

前もって感謝します!

4

1 に答える 1

5

Page-Object と Watir の最新バージョン (それぞれ v2.2.1 と v6.7.3) を使用している場合attribute_value、廃止予定の警告は表示されなくなります。#attributeとの両方#attribute_valueがサポートされています。

#attribute古いバージョンの Page-Object では、次のメソッドを使用する必要があります。

image_status = the_image_element.attribute('class')
于 2012-12-13T12:55:53.153 に答える