Simulate pressing an access key. This may change the focus, may click buttons and may invoke JavaScript. @param accessKey the key that will be pressed @return the element that has the focus after pressing this access key or null if no element has the focus. @throws IOException if an IO erro
(final char accessKey)
| 1588 | * would only happen if the access key triggered a button which in turn caused a page load) |
| 1589 | */ |
| 1590 | public DomElement pressAccessKey(final char accessKey) throws IOException { |
| 1591 | final HtmlElement element = getHtmlElementByAccessKey(accessKey); |
| 1592 | if (element != null) { |
| 1593 | element.focus(); |
| 1594 | if (element instanceof HtmlAnchor |
| 1595 | || element instanceof HtmlArea |
| 1596 | || element instanceof HtmlButton |
| 1597 | || element instanceof HtmlInput |
| 1598 | || element instanceof HtmlLabel |
| 1599 | || element instanceof HtmlLegend |
| 1600 | || element instanceof HtmlTextArea) { |
| 1601 | final Page newPage = element.click(); |
| 1602 | |
| 1603 | if (newPage != this && getFocusedElement() == element) { |
| 1604 | // The page was reloaded therefore no element on this page will have the focus. |
| 1605 | getFocusedElement().blur(); |
| 1606 | } |
| 1607 | } |
| 1608 | } |
| 1609 | |
| 1610 | return getFocusedElement(); |
| 1611 | } |
| 1612 | |
| 1613 | /** |
| 1614 | * Move the focus to the next element in the tab order. To determine the specified tab |