/** {@inheritDoc} */ @Override protected void runJavaScript(final HtmlPage page) { if (script_ == null) { return; } page.executeJavaScriptIfPossible(script_, "JavaScriptStringJob", 1); }
/** {@inheritDoc} */ @Override protected void runJavaScript(final HtmlPage page) { if (script_ == null) { return; } page.executeJavaScriptIfPossible(script_, "JavaScriptStringJob", 1); }
/** {@inheritDoc} */ @Override protected void runJavaScript(final HtmlPage page) { if (script_ == null) { return; } page.executeJavaScriptIfPossible(script_, "JavaScriptStringJob", 1); }
/** * <p>Executes the specified JavaScript code within the page. The usage would be similar to what can * be achieved to execute JavaScript in the current page by entering "javascript:...some JS code..." * in the URL field of a native browser.</p> * <p><b>Note:</b> the provided code won't be executed if JavaScript has been disabled on the WebClient * (see {@link WebClient#isJavaScriptEnabled()}.</p> * @param sourceCode the JavaScript code to execute * @return a ScriptResult which will contain both the current page (which may be different than * the previous page) and a JavaScript result object */ public ScriptResult executeJavaScript(final String sourceCode) { return executeJavaScriptIfPossible(sourceCode, "injected script", 1); }
/** * <p>Executes the specified JavaScript code within the page. The usage would be similar to what can * be achieved to execute JavaScript in the current page by entering "javascript:...some JS code..." * in the URL field of a native browser.</p> * <p><b>Note:</b> the provided code won't be executed if JavaScript has been disabled on the WebClient * (see {@link WebClient#isJavaScriptEnabled()}.</p> * @param sourceCode the JavaScript code to execute * @return a ScriptResult which will contain both the current page (which may be different than * the previous page) and a JavaScript result object */ public ScriptResult executeJavaScript(final String sourceCode) { return executeJavaScriptIfPossible(sourceCode, "injected script", 1); }
/** * <p>Executes the specified JavaScript code within the page. The usage would be similar to what can * be achieved to execute JavaScript in the current page by entering "javascript:...some JS code..." * in the URL field of a native browser.</p> * <p><b>Note:</b> the provided code won't be executed if JavaScript has been disabled on the WebClient * (see {@link WebClient#isJavaScriptEnabled()}.</p> * @param sourceCode the JavaScript code to execute * @return a ScriptResult which will contain both the current page (which may be different than * the previous page) and a JavaScript result object */ public ScriptResult executeJavaScript(final String sourceCode) { return executeJavaScriptIfPossible(sourceCode, "injected script", 1); }
public void execute() throws Exception { if (newLocation.startsWith(JAVASCRIPT_PREFIX)) { final String script = newLocation.substring(11); page.executeJavaScriptIfPossible(script, "new location value", 1); return; } try { final URL url = page.getFullyQualifiedUrl(newLocation); final URL oldUrl = page.getWebResponse().getRequestSettings().getUrl(); if (url.sameFile(oldUrl) && !StringUtils.equals(url.getRef(), oldUrl.getRef())) { // If we're just setting or modifying the hash, avoid a server hit. jsxSet_hash(newLocation); return; } final WebWindow webWindow = getWindow().getWebWindow(); webWindow.getWebClient().getPage(webWindow, new WebRequestSettings(url)); } catch (final MalformedURLException e) { LOG.error("jsxSet_location('" + newLocation + "') Got MalformedURLException", e); throw e; } catch (final IOException e) { LOG.error("jsxSet_location('" + newLocation + "') Got IOException", e); throw e; } } };
public void execute() throws Exception { if (newLocation.startsWith(JAVASCRIPT_PREFIX)) { final String script = newLocation.substring(11); page.executeJavaScriptIfPossible(script, "new location value", 1); return; } try { final URL url = page.getFullyQualifiedUrl(newLocation); final URL oldUrl = page.getWebResponse().getRequestSettings().getUrl(); if (url.sameFile(oldUrl) && !StringUtils.equals(url.getRef(), oldUrl.getRef())) { // If we're just setting or modifying the hash, avoid a server hit. jsxSet_hash(newLocation); return; } final WebWindow webWindow = getWindow().getWebWindow(); webWindow.getWebClient().getPage(webWindow, new WebRequestSettings(url)); } catch (final MalformedURLException e) { LOG.error("jsxSet_location('" + newLocation + "') Got MalformedURLException", e); throw e; } catch (final IOException e) { LOG.error("jsxSet_location('" + newLocation + "') Got IOException", e); throw e; } } };
public void execute() throws Exception { if (newLocation.startsWith(JAVASCRIPT_PREFIX)) { final String script = newLocation.substring(11); page.executeJavaScriptIfPossible(script, "new location value", 1); return; } try { final URL url = page.getFullyQualifiedUrl(newLocation); final URL oldUrl = page.getWebResponse().getRequestSettings().getUrl(); if (url.sameFile(oldUrl) && !StringUtils.equals(url.getRef(), oldUrl.getRef())) { // If we're just setting or modifying the hash, avoid a server hit. jsxSet_hash(newLocation); return; } final WebWindow webWindow = getWindow().getWebWindow(); webWindow.getWebClient().getPage(webWindow, new WebRequestSettings(url)); } catch (final MalformedURLException e) { LOG.error("jsxSet_location('" + newLocation + "') Got MalformedURLException", e); throw e; } catch (final IOException e) { LOG.error("jsxSet_location('" + newLocation + "') Got IOException", e); throw e; } } };
LOG.debug("Executing JavaScript: " + code); ((HtmlPage) getPage()).executeJavaScriptIfPossible(code, code, getStartLineNumber());
LOG.debug("Executing JavaScript: " + code); ((HtmlPage) getPage()).executeJavaScriptIfPossible(code, code, getStartLineNumber());
private WebResponse makeWebResponseForJavaScriptUrl(final WebWindow webWindow, final URL url, final String charset) throws FailingHttpStatusCodeException, IOException { final HtmlPage page; if (webWindow instanceof FrameWindow) { final FrameWindow frameWindow = (FrameWindow) webWindow; page = frameWindow.getEnclosingPage(); } else { Page currentPage = webWindow.getEnclosedPage(); if (currentPage == null) { // Starting with a JavaScript URL; quickly fill an "about:blank". currentPage = getPage(webWindow, new WebRequestSettings(WebClient.URL_ABOUT_BLANK)); } page = (HtmlPage) currentPage; } final ScriptResult r = page.executeJavaScriptIfPossible(url.toExternalForm(), "JavaScript URL", 1); if ((r != null && r.getJavaScriptResult() == null) || ScriptResult.isUndefined(r)) { // No new WebResponse to produce. return webWindow.getEnclosedPage().getWebResponse(); } final String contentString = r.getJavaScriptResult().toString(); return new StringWebResponse(contentString, charset, url); }
private WebResponse makeWebResponseForJavaScriptUrl(final WebWindow webWindow, final URL url, final String charset) throws FailingHttpStatusCodeException, IOException { final HtmlPage page; if (webWindow instanceof FrameWindow) { final FrameWindow frameWindow = (FrameWindow) webWindow; page = frameWindow.getEnclosingPage(); } else { Page currentPage = webWindow.getEnclosedPage(); if (currentPage == null) { // Starting with a JavaScript URL; quickly fill an "about:blank". currentPage = getPage(webWindow, new WebRequestSettings(WebClient.URL_ABOUT_BLANK)); } page = (HtmlPage) currentPage; } final ScriptResult r = page.executeJavaScriptIfPossible(url.toExternalForm(), "JavaScript URL", 1); if ((r != null && r.getJavaScriptResult() == null) || ScriptResult.isUndefined(r)) { // No new WebResponse to produce. return webWindow.getEnclosedPage().getWebResponse(); } final String contentString = r.getJavaScriptResult().toString(); return new StringWebResponse(contentString, charset, url); }
private WebResponse makeWebResponseForJavaScriptUrl(final WebWindow webWindow, final URL url, final String charset) throws FailingHttpStatusCodeException, IOException { final HtmlPage page; if (webWindow instanceof FrameWindow) { final FrameWindow frameWindow = (FrameWindow) webWindow; page = frameWindow.getEnclosingPage(); } else { Page currentPage = webWindow.getEnclosedPage(); if (currentPage == null) { // Starting with a JavaScript URL; quickly fill an "about:blank". currentPage = getPage(webWindow, new WebRequestSettings(WebClient.URL_ABOUT_BLANK)); } page = (HtmlPage) currentPage; } final ScriptResult r = page.executeJavaScriptIfPossible(url.toExternalForm(), "JavaScript URL", 1); if ((r != null && r.getJavaScriptResult() == null) || ScriptResult.isUndefined(r)) { // No new WebResponse to produce. return webWindow.getEnclosedPage().getWebResponse(); } final String contentString = r.getJavaScriptResult().toString(); return new StringWebResponse(contentString, charset, url); }
return page.executeJavaScriptIfPossible(href, "javascript url", getStartLineNumber()).getNewPage();
return page.executeJavaScriptIfPossible(href, "javascript url", getStartLineNumber()).getNewPage();
return page.executeJavaScriptIfPossible(href, "javascript url", getStartLineNumber()).getNewPage();
final HtmlPage page = (HtmlPage) getPage(); if (TextUtil.startsWithIgnoreCase(href, JAVASCRIPT_PREFIX)) { return page.executeJavaScriptIfPossible( href, "javascript url", getStartLineNumber()).getNewPage();
final HtmlPage page = (HtmlPage) getPage(); if (TextUtil.startsWithIgnoreCase(href, JAVASCRIPT_PREFIX)) { return page.executeJavaScriptIfPossible( href, "javascript url", getStartLineNumber()).getNewPage();
final HtmlPage page = (HtmlPage) getPage(); if (TextUtil.startsWithIgnoreCase(href, JAVASCRIPT_PREFIX)) { return page.executeJavaScriptIfPossible( href, "javascript url", getStartLineNumber()).getNewPage();