而不是通过VoiceOver或类似的软件,我想要一个函数,它可以接受一个元素id作为参数,并返回alt文本或标签,以便我可以验证文本是否正确。
欢迎任何其他建议。
发布于 2013-05-24 14:06:39
您可以使用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.https://stackoverflow.com/questions/16728403
复制相似问题