webElement.getAttribute()在selenium中不起作用

时间:2013-11-04 04:16:24

标签: selenium

我正在使用selenium来自动化Web应用程序的测试用例,因为我必须获得工具提示文本

我试过

String result =element.getAttribute("span");

但这是重新调整null。我怎样才能得到文字?

1 个答案:

答案 0 :(得分:1)

element.getAttribute("span");

span不能是给定元素的属性。我猜你误解了getAttribute()方法。

例如

<a href="http://example.com" title="Example Site">Example</a>

对于上面的锚标记,为了获得标题属性的值,您可以使用:

element.getAttribute("title");

其中element指的是上面的锚元素。