我正在使用selenium来自动化Web应用程序的测试用例,因为我必须获得工具提示文本
我试过
String result =element.getAttribute("span");
但这是重新调整null。我怎样才能得到文字?
答案 0 :(得分:1)
element.getAttribute("span");
span
不能是给定元素的属性。我猜你误解了getAttribute()
方法。
例如
<a href="http://example.com" title="Example Site">Example</a>
对于上面的锚标记,为了获得标题属性的值,您可以使用:
element.getAttribute("title");
其中element指的是上面的锚元素。