com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController Java Examples

The following examples show how to use com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IntegrationTest.java    From warnings-ng-plugin with MIT License 5 votes vote down vote up
@SuppressFBWarnings(value = "LG", justification = "Setting the logger here helps to clean up the console log for tests")
static WebClient create(final JenkinsRule jenkins, final boolean isJavaScriptEnabled) {
    WebClient webClient = jenkins.createWebClient();
    webClient.setCssErrorHandler(new SilentCssErrorHandler());
    java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(Level.SEVERE);
    webClient.setIncorrectnessListener((s, o) -> {
    });

    webClient.setJavaScriptEnabled(isJavaScriptEnabled);
    webClient.setJavaScriptErrorListener(new IntegrationTestJavaScriptErrorListener());
    webClient.setAjaxController(new NicelyResynchronizingAjaxController());
    webClient.getCookieManager().setCookiesEnabled(isJavaScriptEnabled);
    webClient.getOptions().setCssEnabled(isJavaScriptEnabled);

    webClient.getOptions().setDownloadImages(false);
    webClient.getOptions().setUseInsecureSSL(true);
    webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
    webClient.getOptions().setThrowExceptionOnScriptError(false);
    webClient.getOptions().setPrintContentOnFailingStatusCode(false);

    return webClient;
}
 
Example #2
Source File: HtmlUnitDownloader.java    From NetDiscovery with Apache License 2.0 5 votes vote down vote up
public HtmlUnitDownloader() {

        this.webClient = new WebClient(BrowserVersion.CHROME);
        this.webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
        this.webClient.getOptions().setThrowExceptionOnScriptError(false);
        this.webClient.getOptions().setRedirectEnabled(false);
        this.webClient.getOptions().setCssEnabled(false);
        this.webClient.setJavaScriptTimeout(1000);
        this.webClient.getOptions().setJavaScriptEnabled(true);
        this.webClient.setAjaxController(new NicelyResynchronizingAjaxController());//设置支持AJAX
    }
 
Example #3
Source File: GSWorker.java    From slr-toolkit with Eclipse Public License 1.0 4 votes vote down vote up
public GSWorker(PrintWriter output, String asQ, String asEpq, String asOq, String asEq, String asOcct,
		String asSauthors, String asPublication, String asYlo, String asYhi) {
	webClient = new WebClient(BrowserVersion.CHROME);
	webClient.getOptions().setJavaScriptEnabled(true);
	webClient.setAjaxController(new NicelyResynchronizingAjaxController());
	webClient.setAjaxController(new AjaxController() {
		@Override
		public boolean processSynchron(HtmlPage page, WebRequest request, boolean async) {
			return true;
		}
	});
	webClient.getOptions().setScreenHeight(768);
	webClient.getOptions().setScreenWidth(1024);
	webClient.getCookieManager().setCookiesEnabled(true);

	base = scholar + "scholar?";
	try {
		if (asQ == null) {
			asQ = "";
		}
		base += "as_q=" + URLEncoder.encode(asQ.replace(" ", "+"), ENCODING) + "&";

		if (asEpq == null) {
			asEpq = "";
		}
		base += "as_epq=" + URLEncoder.encode(asEpq.replace(" ", "+"), ENCODING) + "&";

		if (asOq == null) {
			asOq = "";
		}
		base += "as_oq=" + URLEncoder.encode(asOq.replace(" ", "+"), ENCODING) + "&";

		if (asEq == null) {
			asEq = "";
		}
		base += "as_eq=" + URLEncoder.encode(asEq.replace(" ", "+"), ENCODING) + "&";

		if (asOcct == null) {
			asOcct = "";
		}
		base += "as_occt=" + URLEncoder.encode(asOcct.replace(" ", "+"), ENCODING) + "&";

		if (asSauthors == null) {
			asSauthors = "";
		}
		base += "as_sauthors=" + URLEncoder.encode(asSauthors.replace(" ", "+"), ENCODING) + "&";

		if (asPublication == null) {
			asPublication = "";
		}
		base += "as_publication=" + URLEncoder.encode(asPublication.replace(" ", "+"), ENCODING) + "&";

		if (asYlo == null) {
			asYlo = "";
		}
		base += "as_ylo=" + URLEncoder.encode(asYlo.replace(" ", "+"), ENCODING) + "&";

		if (asYhi == null) {
			asYhi = "";
		}
		base += "as_yhi=" + URLEncoder.encode(asYhi.replace(" ", "+"), ENCODING) + "&";
	} catch (UnsupportedEncodingException e) {
		e.printStackTrace();
	}
	base += "hl=de&as_sdt=0%2C5";

	this.out = output;
	out.write("@Comment { Base-URL: " + base + " }\n\n");
	out.flush();
}