MCPcopy Index your code
hub / github.com/HtmlUnit/htmlunit / pressAccessKey

Method pressAccessKey

src/main/java/org/htmlunit/html/HtmlPage.java:1590–1611  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 4

accessKeysMethod · 0.95
pressAccessKey_ButtonMethod · 0.95

Calls 5

getFocusedElementMethod · 0.95
focusMethod · 0.65
clickMethod · 0.45
blurMethod · 0.45

Tested by 4

accessKeysMethod · 0.76
pressAccessKey_ButtonMethod · 0.76