/** Does this element currently have the focus. */
 @Override
 public boolean hasFocus() {
   JavascriptExecutorFacade js = new JavascriptExecutorFacade(driver);
   WebElement activeElement =
       (WebElement) js.executeScript("return window.document.activeElement");
   return getElement().equals(activeElement);
 }
  @Test
  public void should_be_able_to_set_focus_directly() {
    StaticSitePage page = getPage();

    JavascriptExecutorFacade js = new JavascriptExecutorFacade(page.getDriver());
    js.executeScript("$('#firstname').focus();");

    assertThat(page.element(page.firstName).hasFocus(), is(true));
  }