ruby – 如何获取page_object元素的attribute_value?
发布时间:2020-12-17 03:15:31 所属栏目:百科 来源:网络整理
导读:想象一下,我有一个像这样的图像: the_image = @browser.image(:id,'image01') 获得其类的价值的方法可以是: image_status = the_image.attribute_value('class') 好.我正在使用page_object gem并假设我将图像作为元素,如: image(:the_image,:id = 'image0
想象一下,我有一个像这样的图像:
the_image = @browser.image(:id,'image01') 获得其类的价值的方法可以是: image_status = the_image.attribute_value('class') 好.我正在使用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. 如何使用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') (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |