@Override public String getEval(String script) { return selenium.getEval(script); }
@Override public String getEval(String script) { return selenium.getEval(script); }
/** Returns the body text of the current page */ public String getText() { return selenium.getEval("this.page().bodyText()"); }
public String getEval(String script) { return selenium.getEval(script); }
public String getEval(String script) { return sel.getEval(script); }
private String getString(String locator, String property) { return session.getEval("this.browserbot.findElement(\"" + locator + "\")." + property + ";"); }
private void scrollWindowToLocation(int x, int y) { session.getEval("window.scrollTo(" + x + ", " + y + ")"); }
private int getInt(String locator, String property) { return Integer.parseInt(session.getEval("this.browserbot.findElement(\"" + locator + "\")." + property + ";")); }
private static int evaluateAsInt(Selenium session, String queryString) { return Integer.parseInt(session.getEval(queryString)); }
private void scrollElementToLocation(String locator, int x, int y) { StringBuilder builder = new StringBuilder(); builder.append("var element = this.browserbot.findElement(\"" + locator + "\");"); builder.append("element.scrollLeft = " + x + ";"); builder.append("element.scrollTop = " + y + ";"); session.getEval(builder.toString()); }
@Override public boolean containsScript(JavaScript javaScript) { final String identification = javaScript.getIdentification(); String evaluated = selenium.getEval("document.getElementById('" + identification + "') ? true : false"); return Boolean.valueOf(evaluated); }
private int getWindowXScroll() { StringBuilder builder = new StringBuilder(); if (BrowserConfiguration.isIE(session)) { builder.append("document.body.scrollLeft;"); } else { builder.append("window.pageXOffset;"); } return Integer.parseInt(session.getEval(builder.toString())); }
private int getWindowYScroll() { StringBuilder builder = new StringBuilder(); if (BrowserConfiguration.isIE(session)) { builder.append("document.body.scrollTop;"); } else { builder.append("window.pageYOffset;"); } return Integer.parseInt(session.getEval(builder.toString())); }
@Override public String getEval(JavaScript script) { return selenium.getEval(script.toString()); }
/** * Get the JavaScript support status in the browser. * * @return with the current status */ @Override public boolean getJavascriptSupport() { return Boolean.parseBoolean(getWebDriverUtil().getSelenium().getEval(GET_JS)); } }
/** * Only the ones we think might be used at some point are recognized here. To know all of them, see wikipedia here: <code>http://fr.wikipedia.org/wiki/User-Agent</code> */ public static Browser getBrowser(Selenium session) { return UserAgent.parseUserAgentString(session.getEval("navigator.userAgent")).getBrowser(); }
private String evaljQuery(String expression) { selenium.runScript("if(window.tQuery){(function($, jQuery){window.testatoo_tmp=" + expression + ";})(window.tQuery, window.tQuery);}else{window.testatoo_tmp='__TQUERY_MISSING__';}"); String s = selenium.getEval("window.testatoo_tmp"); if ("__TQUERY_MISSING__".equals(s)) { selenium.runScript(addScript("tquery-1.7.2.js") + addScript("tquery-simulate.js") + addScript("tquery-util.js")); selenium.runScript("if(window.tQuery){(function($, jQuery){window.testatoo_tmp=" + expression + ";})(window.tQuery, window.tQuery);}else{window.testatoo_tmp='__TQUERY_MISSING__';}"); s = selenium.getEval("window.testatoo_tmp"); } return s; }
private void assertCSS(String elementId, String cssProperty, String expected) { // See http://groups.google.com/group/selenium-users/browse_thread/thread/f21e0a43c9913d42 String actual = selenium.getEval(String.format("window.document.defaultView.getComputedStyle(window.document.getElementById('%s'), null).getPropertyValue('%s')", elementId, cssProperty)); assertEquals(actual, expected, String.format("CSS property '%s' of '%s' should be '%s'.", cssProperty, elementId, expected)); }
/** * Set the JavaScript support in the browser. * * @param status parameter specifies the status to set */ @Override protected void setJavascriptSupport(boolean status) { if (getJavascriptSupport() == status) { getTc().logComment("Browser JavaScript support status [" + status + "] already set."); return; } getWebDriverUtil().getSelenium().getEval(SET_JS.replace("%STATUS%", Boolean.toString(status))); getTc().logComment("Browser Javascript support status [" + status + "] set."); }
/** * Sets the browser width and height according to the argument dimension. * * @param dimension the dimension to set */ public void setBrowserSize(Dimension dimension) { if (dimension == null) { wdu.getSelenium().windowMaximize(); } else { wdu.getSelenium().getEval("window.resizeTo(" + dimension.getWidth() + "," + dimension.getHeight() + "); window.moveTo(0,0);"); } }