Exemple #1
0
 /**
  * Creates and inserts a new button to DOM, clicks on it and removes it.
  *
  * @param browser
  */
 public static void performUniversalBlur(WebDriver browser) {
   // reuse FirefoxKeyboardWorkaround
   FirefoxKeyboardWorkaround fkw =
       JSInterfaceFactory.create(GrapheneContext.lastContext(), FirefoxKeyboardWorkaround.class);
   fkw.insertButtonWorkaround();
   new Actions(browser).moveToElement(fkw.getButtonElement()).click().perform();
 }
Exemple #2
0
 /**
  * When using Firefox and body element is focused, focus on the page from url/address bar,
  * otherwise nothing happens. Workaround for Selenium issue <a
  * href="https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/7937">#7937</a>
  */
 public static void performFirefoxKeyboardWorkaround(WebDriver browser) {
   if (browser instanceof FirefoxDriver) {
     FirefoxKeyboardWorkaround fkw =
         JSInterfaceFactory.create(GrapheneContext.lastContext(), FirefoxKeyboardWorkaround.class);
     // is body element focused and workaround was not invoked?
     if (!fkw.isInvoked() && fkw.getActiveElementTagName().equalsIgnoreCase("body")) {
       // insert the button element
       fkw.insertButtonWorkaround();
       // click on the inserted button to focus on the page and remove the button from DOM (after
       // click)
       fkw.getButtonElement().click();
     }
   }
 }