Eze*_*tha 5 ruby cucumber watir-webdriver pageobjects page-object-gem
想象一下,我有一个像这样的图像:
the_image = @browser.image(:id, 'image01')
Run Code Online (Sandbox Code Playgroud)
获得其类的价值的方法可以是:
image_status = the_image.attribute_value('class')
Run Code Online (Sandbox Code Playgroud)
好.我正在使用page_object gem并假设我将图像作为元素,如:
image(:the_image, :id => 'image01')
Run Code Online (Sandbox Code Playgroud)
要获取attribute_value,我可以使用:
image_status = the_image_element.attribute_value('class')
Run Code Online (Sandbox Code Playgroud)
......但是我得到了一份弃权警告:
*** 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.
Run Code Online (Sandbox Code Playgroud)
如何class使用page_object元素获取值?当然答案很简单,但我没有找到它.你能告诉我路吗?
先感谢您!
如果您使用的是最新版本的Page-Object和Watir(分别为v2.2.1和v6.7.3),则attribute_value不再提供弃用警告.这两个#attribute和#attribute_value支持.
对于旧版本的Page-Object,您需要使用以下#attribute方法:
image_status = the_image_element.attribute('class')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3808 次 |
| 最近记录: |