【发布时间】:2012-12-13 11:45:02
【问题描述】:
想象一下我有这样的图像:
the_image = @browser.image(:id, 'image01')
获取其类的值的方法可能是:
image_status = the_image.attribute_value('class')
好的。我正在使用 page_object gem,假设我将图像作为元素,例如:
image(:the_image, :id => 'image01')
要获取我可以使用的属性值:
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.
如何使用 page_object 元素获取 class 值?当然答案很简单,但我没有找到。你能告诉我路吗?
提前谢谢你!
【问题讨论】:
-
该错误未显示在您的页面对象类的上下文中。也许您可以在问题中添加更多内容?
-
嗨戴夫!没有错误,只有警告。事实上,该方法工作正常。问题是我不知道如何本地使用页面对象获取属性值。 Justin Ko 给了我答案:
yourelement_element.attribute('attribute_type')
标签: ruby cucumber watir-webdriver pageobjects page-object-gem