Package org.openqa.selenium

Examples of org.openqa.selenium.JavascriptExecutor


   *             when javascript execution failed.
   */
  @Override
  public Object executeJavaScript(String code) throws CrawljaxException {
    try {
      JavascriptExecutor js = (JavascriptExecutor) browser;
      return js.executeScript(code);
    } catch (WebDriverException e) {
      throwIfConnectionException(e);
      throw new CrawljaxException(e);
    }
  }
View Full Code Here


   *             when javascript execution failed.
   */
  @Override
  public Object executeJavaScript(String code) throws CrawljaxException {
    try {
      JavascriptExecutor js = (JavascriptExecutor) browser;
      return js.executeScript(code);
    } catch (WebDriverException e) {
      throwIfConnectionException(e);
      throw new CrawljaxException(e);
    }
  }
View Full Code Here

  }

  //@JavascriptEnabled
  @Test
  public void testJavaScriptShouldExecuteInTheContextOfTheCurrentFrame() {
    JavascriptExecutor executor = (JavascriptExecutor) driver;

    driver.get(pages.framesetPage);
    assertTrue((Boolean) executor.executeScript("return window == window.top"));
    driver.switchTo().frame("third");
    assertTrue((Boolean) executor.executeScript("return window != window.top"));
  }
View Full Code Here

  public JasmineResult execute(URL runnerUrl, File junitXmlReport, WebDriver driver, int timeout, boolean debug, Log log, String format) {
    try {
      if (!(driver instanceof JavascriptExecutor)) {
        throw new RuntimeException("The provided web driver can't execute JavaScript: " + driver.getClass());
      }
      JavascriptExecutor executor = (JavascriptExecutor) driver;
      driver.get(runnerUrl.toString());
      this.waitForRunnerToFinish(driver, timeout, debug, log);

      this.checkForConsoleErrors(driver, log);
View Full Code Here

        "return junitXmlReporter.report(window.jsApiReporter,"+debug+");");
    return junitReport.toString();
  }

  private void waitForRunnerToFinish(final WebDriver driver, int timeout, boolean debug, Log log) throws InterruptedException {
    final JavascriptExecutor executor = (JavascriptExecutor) driver;
    new WebDriverWait(driver, timeout, 1000).until(new Predicate<WebDriver>() {
      @Override
      public boolean apply(WebDriver input) {
        return SpecRunnerExecutor.this.executionFinished(executor);
      }
View Full Code Here

    WebElement processButton;

    public String find(){
        String s = null;
        if (driver instanceof JavascriptExecutor) {
            JavascriptExecutor js = (JavascriptExecutor)driver;
            topTextField.sendKeys(String.valueOf(js.executeScript(TOP_COORDINATE_JS)));
            leftTextField.sendKeys(String.valueOf(js.executeScript(LEFT_COORDINATE_JS)));
            processButton.click();
            Alert alert = driver.switchTo().alert();
            s = alert.getText();
            alert.accept();
            //driver.switchTo().defaultContent();
View Full Code Here

      selenium = new WebDriverBackedSelenium(driver, Config.inst().TEAMMATES_URL);

      /*
       * Chrome hack. Currently Chrome doesn't support confirm() yet. http://code.google.com/p/selenium/issues/detail?id=27
       */
      JavascriptExecutor js = (JavascriptExecutor) driver;
      js.executeScript("window.confirm = function(msg){ return true;};");

    } else {

      System.out.println("Using " + Config.inst().BROWSER);

View Full Code Here

     * Huy: I have no idea why the driver.switchTo().alert() approach doesn't work even in Firefox (it supposed to!). This is a workaround to press Yes in the confirmation box. Same for function
     * below for No.
     */

    // if (Config.inst().BROWSER.equals("chrome")) {
    JavascriptExecutor js = (JavascriptExecutor) driver;
    js.executeScript("window.confirm = function(msg){ return true;};");
    // }
  }
View Full Code Here

    // }
  }

  public static void chromeConfirmNo() {
    // if (Config.inst().BROWSER.equals("chrome")) {
    JavascriptExecutor js = (JavascriptExecutor) driver;
    js.executeScript("window.confirm = function(msg){ return false;};");
    // }
  }
View Full Code Here

        sendContextMessage(step);
    }

    private void sendContextMessage(String step) {
        try {
            JavascriptExecutor je = (JavascriptExecutor) webDriverProvider.get();
            je.executeScript("sauce:context=Step: " + step);
        } catch (Exception e) {
        }
    }
View Full Code Here

TOP

Related Classes of org.openqa.selenium.JavascriptExecutor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.