Test tabbing to the next element. @throws Exception if something goes wrong
()
| 32 | * @throws Exception if something goes wrong |
| 33 | */ |
| 34 | @Test |
| 35 | @Alerts({"focus-0", "blur-0", "focus-1", "blur-1", "focus-2"}) |
| 36 | public void tabNext() throws Exception { |
| 37 | final String html = DOCTYPE_HTML |
| 38 | + "<html>\n" |
| 39 | + "<head><title>First</title>\n" |
| 40 | + "</head>\n" |
| 41 | + "<body>\n" |
| 42 | + " <form name='form1' method='post' onsubmit='return false;'>\n" |
| 43 | + " <input type='submit' name='submit0' id='submit0' " |
| 44 | + "tabindex='1' onblur='alert(\"blur-0\")' onfocus='alert(\"focus-0\")'>\n" |
| 45 | + " <input type='submit' name='submit1' id='submit1' " |
| 46 | + "tabindex='2' onblur='alert(\"blur-1\")' onfocus='alert(\"focus-1\")'>\n" |
| 47 | + " <input type='submit' name='submit2' id='submit2' " |
| 48 | + "tabindex='3' onblur='alert(\"blur-2\")' onfocus='alert(\"focus-2\")'>\n" |
| 49 | + " <div id='div1'>foo</div>\n" |
| 50 | + " </form>\n" |
| 51 | + "</body></html>"; |
| 52 | |
| 53 | final List<String> collectedAlerts = new ArrayList<>(); |
| 54 | final HtmlPage page = loadPage(html, collectedAlerts); |
| 55 | |
| 56 | assertEquals("submit0", page.tabToNextElement().getAttribute("name")); |
| 57 | assertEquals("submit1", page.tabToNextElement().getAttribute("name")); |
| 58 | assertEquals("submit2", page.tabToNextElement().getAttribute("name")); |
| 59 | |
| 60 | assertEquals(getExpectedAlerts(), collectedAlerts); |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Test tabbing to the previous element. |
nothing calls this directly
no test coverage detected