Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the attribute_value of a page_object element?

Imagine i have a image like:

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

The way to get the value of its class could be:

image_status = the_image.attribute_value('class')

Ok. I'm using page_object gem and lets suppose i have the image as element, like:

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

To get the attribute_value i can use:

image_status = the_image_element.attribute_value('class')

...but i get a DEPRECATION WARNING:

*** 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.

How can i get the class value using the page_object element? Sure the answer is easy but i didn't found it. Can you please tell me the way?

Thank you in advance!

like image 937
Pablo Gómez Avatar asked Dec 13 '12 11:12

Pablo Gómez


1 Answers

If you are using the latest versions of Page-Object and Watir (v2.2.1 and v6.7.3 respectively), the attribute_value will no longer give a deprecation warning. Both #attribute and #attribute_value are supported.

For older version of Page-Object, you need to use the #attribute method:

image_status = the_image_element.attribute('class')
like image 139
Justin Ko Avatar answered Sep 28 '22 07:09

Justin Ko