### Question:
AlternativeTextForImageButtonRule extends AbstractRule { @Override protected void applyTo(Page page, Violations violations) { for (HtmlInput input : page.findAllInputTags()) { if (isImageButton(input) && !hasNonEmptyAttribute(input, "alt")) { violations.add(createViolation(input, page, RULE_MESSAGE)); } } }  @Override String getName();  }### Answer:
@Test public void imageButtonWithMissingAlternativeText() throws Exception { String content = "<html><body><form><input type=\"image\"/></form></body></html>"; Violations violations = rule.applyTo(toHtmlPage(content)); assertViolations(violations, rule, 1); }
@Test public void imageButtonWithAlternativeTextPresent() throws Exception { String content = "<html><body><form><input type=\"image\" alt=\"Create Account\"/></form></body></html>"; Violations violations = rule.applyTo(toHtmlPage(content)); assertNoViolations(violations, rule); }