How to get title attribute of input element? - webdriver
4 answers
The answer provided by Jim Evans is correct, but for a more specific one I would suggest something like below. Remember that pasta copy may not work, and you need to change something to be able to work with your full HTML.
List<WebElement> elements = driver.findElements(By.tagName("input")); for (WebElement element : elements) { if (element.getAttribute("type").equals("image")) { System.out.println(element.getAttribute("title")); } } The above code will loop on all web pages that are of type = "image" and print the "title" attribute on each of them.
However, you should vote for Jim as the right one, though.
+3