Package org.openqa.selenium

Examples of org.openqa.selenium.JavascriptExecutor.executeScript()


   */
  @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.
   */
  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

   */
  @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

        sb.append("req.setRequestHeader('Accept', 'application/json');\n");
        sb.append("req.send(null);\n");
        sb.append("return req.status + '///' + req.responseText;\n");

        JavascriptExecutor js = (JavascriptExecutor) driver;
        String response = (String) js.executeScript(sb.toString());
        return response.split("///");
    }
}
View Full Code Here

    @Override
    @SuppressWarnings("unchecked")
    public Map<String, Map<String, Long>> extractCoverageDataVariable() {
        final JavascriptExecutor js = (JavascriptExecutor) driver;
        return (Map<String, Map<String, Long>>) js.executeScript("return window." + ScriptInstrumenter.COVERAGE_VARIABLE_NAME);
    }

    @Override
    public String instrument(final String sourceCode, final String sourceName, final int lineNumber) {
        return instrumenter.instrument(sourceCode, sourceName, lineNumber);
View Full Code Here

     * @param script
     */
    public Object executeScript(final String script) {
        if (javascriptIsSupportedIn(driver)) {
            JavascriptExecutor js = getJavascriptEnabledDriver();
            return js.executeScript(script);
        } else {
            return null;
        }
    }

View Full Code Here

    }

    public Object executeScript(final String script, final Object... params) {
        if (javascriptIsSupportedIn(driver)) {
            JavascriptExecutor js = getJavascriptEnabledDriver();
            return js.executeScript(script, params);
        } else {
            return null;
        }
    }
   
View Full Code Here

        // Of course, no cookie yet(!)
        Cookie c = d.manage().getCookieNamed(ckey);
        assertNull(c);

        // Attempt to create cookie on multiple Google domains
        js.executeScript("javascript:(" +
                "function() {" +
                "   cook = document.cookie;" +
                "   begin = cook.indexOf('"+ckey+"=');" +
                "   var val;" +
                "   if (begin !== -1) {" +
View Full Code Here

        c = d.manage().getCookieNamed(ckey);
        assertNotNull(c);
        assertEquals(cval, c.getValue());

        // Set cookie as empty
        js.executeScript("javascript:(" +
                "function() {" +
                "   var d = Array('com','co.jp','ca','fr','de','co.uk','it','cn','es','com.br');" +
                "   for(var i = 0; i < d.length; i++) {" +
                "       document.cookie='"+ckey+"=;path=/;domain=.google.'+d[i]+'; ';" +
                "   }" +
View Full Code Here

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

    } else {

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

View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.