如何在watir中检索自定义属性? [英] How do I retrieve a custom attribute in watir?

查看:120
本文介绍了如何在watir中检索自定义属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从下面的链接中检索"onclick"属性值:

I'm trying to retrieve the "onclick" attribute value from the below link:

<a onclick="test" href="myurl">aaa</a>

使用link.href可以很好地工作(因此我知道link是正确的对象),但是当使用link.attribute_value("onclick")时,我得到的是win32对象(输入显示#<WIN32OLE:0x2cbdf10>而不是"test"字符串)./p>

Using link.href works fine (So I know link is the correct object) however when using link.attribute_value("onclick") what I get is a win32 object (puts shows #<WIN32OLE:0x2cbdf10> instead of the "test" string).

推荐答案

如果您没有更整洁的解决方案,那就不行了(如果您可以确保开发过程在下次记住这种测试的话) ).尝试:

If you don't get a neater solution, and it's a one off(If you can make sure the development process keeps this kind of testing in mind next time).Try:

onclick_value=browser.html[ %r{<a onclick="(.*?)" href="myurl">}mi, 1 ]

这篇关于如何在watir中检索自定义属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆