String strURL = "https://www.checkmytrip.com" ; java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(java.util.logging.Level.OFF); java.util.logging.Logger.getLogger("org.apache.http").setLevel(java.util.logging.Level.OFF); try (final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_31)) { webClient.setAjaxController(new NicelyResynchronizingAjaxController()); HtmlPage myPage = ((HtmlPage) webClient.getPage(strURL)); webClient.waitForBackgroundJavaScript(10 * 1000); String theContent = myPage.asXml(); System.out.println(theContent); }
@Override protected WebClient modifyWebClient(WebClient client) { client.setAjaxController(new NicelyResynchronizingAjaxController()); //Disables stuff like this "com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify WARNING: Obsolete content type encountered: 'text/javascript'." if (!this.debug) { client.setIncorrectnessListener((message, origin) -> {}); } return client; } }
@Override protected WebClient modifyWebClient(WebClient client) { client.setAjaxController(new NicelyResynchronizingAjaxController()); //Disables stuff like this "com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify WARNING: Obsolete content type encountered: 'text/javascript'." if (!this.debug) { client.setIncorrectnessListener(new IncorrectnessListener() { @Override public void notify(String message, Object origin) { } }); } return client; } }
@Override UnaryOperator<WebClient> customizer() { UnaryOperator<WebClient> setJavascript = client -> { client.getOptions().setThrowExceptionOnScriptError(false); client.setAjaxController(new NicelyResynchronizingAjaxController()); return client; }; return client -> setJavascript.apply(super.customizer().apply(client)); }
/** * {@inheritDoc} */ @Override //@Before public void before() { webClient = new WebClient(getBrowserVersion()); webClient.setAjaxController(new NicelyResynchronizingAjaxController()); }
WebClient webClient = new WebClient(BrowserVersion.FIREFOX_24); webClient.getOptions().setJavaScriptEnabled(true); webClient.getOptions().setThrowExceptionOnScriptError(false); webClient.getOptions().setCssEnabled(false); webClient.setAjaxController(new NicelyResynchronizingAjaxController());
WebClient webClient=new WebClient(BrowserVersion.FIREFOX_3_6); webClient.setAjaxController(new NicelyResynchronizingAjaxController()); webClient.getOptions().setThrowExceptionOnFailingStatusCode(false); webClient.getOptions().setThrowExceptionOnScriptError(false); webClient.waitForBackgroundJavaScript(50000);
private void setupWebClient() { webClient = new WebClient(browser); mockConnection = new MockWebConnection(); webClient.setWebConnection(mockConnection); webClient.setAjaxController(new NicelyResynchronizingAjaxController()); }
/** * {@inheritDoc} */ @Override //@Before public void before() { super.before(); webClient = new WebClient(getBrowserVersion()); webClient.setAjaxController(new NicelyResynchronizingAjaxController()); }
public ExtendWebDriver(boolean enableJavascript) { this(BrowserVersion.CHROME); headerNames = new HashSet<String>(); if(enableJavascript){ setJavascriptEnabled(enableJavascript); WebClient webClient = getWebClient(); webClient.getOptions().setCssEnabled(false); webClient.setAjaxController(new NicelyResynchronizingAjaxController()); //webClient.getOptions().setTimeout(50000); webClient.getOptions().setThrowExceptionOnScriptError(false); } }
final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_17, PROXY_HOST, PROXY_PORT); WebRequest request = new WebRequest(new URL( "http://steamcommunity.com/id/bobcatchris/inventory#730")); webClient.getOptions().setThrowExceptionOnScriptError(false); webClient.setJavaScriptTimeout(10000); webClient.getOptions().setJavaScriptEnabled(true); webClient.setAjaxController(new NicelyResynchronizingAjaxController()); webClient.getOptions().setTimeout(10000); HtmlPage page = webClient.getPage(request); String script="var list = [];\n" + "\n" + "\n" + "var size = Object.keys(g_ActiveInventory.rgInventory).size();\n" + "\n" + "\n" + "\n" + "var counter = 0;\n" + "\n" + "while (counter < size) {\n" + " list.push(g_ActiveInventory.rgInventory[Object.keys(g_ActiveInventory.rgInventory)[counter]].market_name);\n" + " counter +=1;\n" + "}"; Object result = page.executeJavaScript(script).getJavaScriptResult(); System.out.println(result);
WebClient webClient = new WebClient(BrowserVersion.CHROME); webClient.getOptions().setJavaScriptEnabled(true); webClient.getOptions().setCssEnabled(false); webClient.getOptions().setUseInsecureSSL(true); webClient.getOptions().setThrowExceptionOnFailingStatusCode(false); webClient.getCookieManager().setCookiesEnabled(true); webClient.setAjaxController(new NicelyResynchronizingAjaxController()); webClient.getOptions().setThrowExceptionOnScriptError(false); webClient.getCookieManager().setCookiesEnabled(true);
WebClient webClient = new WebClient(BrowserVersion.CHROME); webClient.getOptions().setJavaScriptEnabled(true); webClient.getOptions().setCssEnabled(false); webClient.getOptions().setUseInsecureSSL(true); webClient.getOptions().setThrowExceptionOnFailingStatusCode(false); webClient.getCookieManager().setCookiesEnabled(true); webClient.setAjaxController(new NicelyResynchronizingAjaxController()); webClient.getOptions().setThrowExceptionOnScriptError(false); webClient.getCookieManager().setCookiesEnabled(true);
webClient.setThrowExceptionOnScriptError(false); webClient.setJavaScriptEnabled(true); webClient.setAjaxController(new NicelyResynchronizingAjaxController()); webClient.setJavaScriptTimeout(20000); webClient.waitForBackgroundJavaScript(20000);
final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_17, YOUR_PROXY_HOST, YOUR_PROXY_PORT); WebRequest request = new WebRequest( new URL( "http://bitcoincharts.com/charts/btceUSD#rg60ztgSzm1g10zm2g25zv")); webClient.getOptions().setThrowExceptionOnScriptError(false); webClient.setJavaScriptTimeout(10000); webClient.getOptions().setJavaScriptEnabled(true); webClient.setAjaxController(new NicelyResynchronizingAjaxController()); webClient.getOptions().setTimeout(10000); HtmlPage page = webClient.getPage(request); webClient.waitForBackgroundJavaScript(30000); List<HtmlAnchor> anchors1 = page.getAnchors(); HtmlAnchor link2 = null; for (HtmlAnchor anchor : anchors1) { //System.out.println(anchor.asText()); if (anchor.asText().indexOf("Load raw data") > -1) { link2 = anchor; break; } } page = link2.click();
final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_24); webClient.setAjaxController(new NicelyResynchronizingAjaxController()); webClient.setCssErrorHandler(new SilentCssErrorHandler()); webClient.getOptions().setCssEnabled(true); webClient.getOptions().setRedirectEnabled(true); webClient.getOptions().setAppletEnabled(false); webClient.getOptions().setJavaScriptEnabled(true); webClient.getOptions().setPopupBlockerEnabled(true); webClient.getOptions().setTimeout(10000); webClient.getOptions().setThrowExceptionOnFailingStatusCode(true); webClient.getOptions().setThrowExceptionOnScriptError(true); webClient.getOptions().setPrintContentOnFailingStatusCode(true); webClient.waitForBackgroundJavaScript(5000); try { HtmlPage page = webClient.getPage(URL); System.out.println(page.asText()); } catch (Exception e) { e.printStackTrace(); } webClient.closeAllWindows();
@Test @SpecAssertion(section = CONVERSATION_CONTEXT_EE, id = "l") public void testConversationPropagatedAjax() throws Exception { WebClient webClient = new WebClient(); webClient.setAjaxController(new NicelyResynchronizingAjaxController()); HtmlPage storm = webClient.getPage(getPath("storm-ajax.jsf")); // Begin long-running conversation - note that we use ajax HtmlSubmitInput beginConversationButton = getFirstMatchingElement(storm, HtmlSubmitInput.class, "beginConversationButton"); storm = beginConversationButton.click(); String cid = getFirstMatchingElement(storm, HtmlInput.class, "conversationId").getValueAttribute(); assertFalse(cid.isEmpty()); // Set input value HtmlTextInput stormStrength = getFirstMatchingElement(storm, HtmlTextInput.class, "stormStrength"); stormStrength.setValueAttribute(AJAX_STORM_STRENGTH); // Submit value - note that we use ajax HtmlSubmitInput thunderButton = getFirstMatchingElement(storm, HtmlSubmitInput.class, "thunderButton"); thunderButton.click(); HtmlPage thunder = webClient.getPage(getPath("thunder.jsf", cid)); stormStrength = getFirstMatchingElement(thunder, HtmlTextInput.class, "stormStrength"); assertEquals(stormStrength.getValueAttribute(), AJAX_STORM_STRENGTH); }
wcSpec.getProxyPort()); if (proxyHost == null) wc = new WebClient(wcSpec.getBrowserVersion()); wc.setAjaxController(new NicelyResynchronizingAjaxController()); wc.setWebConnection(new JSFUnitWebConnection(wc.getWebConnection())); wcSpec.setWebClient(wc);
@Override protected WebClient modifyWebClient(WebClient client) { myClient = client; client.getCookieManager().setCookiesEnabled(true); client.getOptions().setJavaScriptEnabled(true); client.getOptions().setCssEnabled(true); client.getOptions().setPopupBlockerEnabled(false); client.setIncorrectnessListener(new SilentIncorrectnessListener()); client.setCssErrorHandler(new QuietCssErrorHandler()); client.setAjaxController(new NicelyResynchronizingAjaxController()); return client; } }
public static WebClient newInstance(final BrowserVersion version) { final WebClient client = new WebClient(version) { @Override public WebResponse loadWebResponse(final WebRequest webRequest) throws IOException { return new WebResponseProxy(super.loadWebResponse(webRequest)); } }; client.setIncorrectnessListener(quietIncorrectnessListener); client.setJavaScriptErrorListener(loggingJsErrorListener); client.setHTMLParserListener(quietHtmlParserListener); client.setCssErrorHandler(quietCssErrorHandler); client.getOptions().setJavaScriptEnabled(true); client.setAjaxController(new NicelyResynchronizingAjaxController()); client.getOptions().setThrowExceptionOnScriptError(false); client.getOptions().setThrowExceptionOnFailingStatusCode(false); client.getOptions().setPrintContentOnFailingStatusCode(false); client.setWebConnection(new HttpWebConnection(client) { @Override protected WebResponse newWebResponseInstance( final WebResponseData responseData, final long loadTime, final WebRequest request) { return new WebResponseProxy(super.newWebResponseInstance(responseData, loadTime, request)); } }); return client; }