Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 selenium 自动化 Web 应用程序的测试用例,因为我必须获取工具提示文本
我试过了
String result =element.getAttribute("span");
但这是重新调整null。我怎样才能得到文字?
element.getAttribute("span");
span不能是给定元素的属性。我猜你误解了getAttribute()方法。
span
getAttribute()
例如
<a href="http://example.com" title="Example Site">Example</a>
对于上面的锚标签,为了获取标题属性的值,您可以使用:
element.getAttribute("title");
其中 element 指的是上述锚元素。