0

而不是通过 VoiceOver 或类似软件,我想要一个可以将元素 ID 作为参数并返回替代文本或标签的函数,以便我可以验证文本是否正确。

欢迎任何其他建议。

4

1 回答 1

1

您可以使用HttpClient从 Web 获取 HTML 代码,并使用该jsoup库来解析代码,然后找出所选元素的属性。下载jsoup jar,放到lib你项目的目录下。

Document doc = Jsoup.parse("..."); // ... is the string of HTML code
Elements inputElement = doc.select("#...").first(); // ... is the id of your element
String alt = inputElement.attr("alt") // select the "alt" attribute.
于 2013-05-24T06:06:39.457 回答