com.gargoylesoftware.htmlunit.WebClient.setAjaxController()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(11.4k)|赞(0)|评价(0)|浏览(185)

本文整理了Java中com.gargoylesoftware.htmlunit.WebClient.setAjaxController()方法的一些代码示例,展示了WebClient.setAjaxController()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebClient.setAjaxController()方法的具体详情如下:
包路径:com.gargoylesoftware.htmlunit.WebClient
类名称:WebClient
方法名:setAjaxController

WebClient.setAjaxController介绍

[英]Sets the current AJAX controller.
[中]设置当前的AJAX控制器。

代码示例

代码示例来源:origin: stackoverflow.com

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);
}

代码示例来源:origin: searls/jasmine-maven-plugin

@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;
 }
}

代码示例来源:origin: com.github.searls/jasmine-maven-plugin

@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;
 }
}

代码示例来源:origin: org.nuxeo.runtime/nuxeo-runtime-test

@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));
}

代码示例来源:origin: org.apache.myfaces.extensions.cdi.test/myfaces-extcdi-cargo-support-module

/**
 * {@inheritDoc}
 */
@Override
//@Before
public void before()
{
  webClient = new WebClient(getBrowserVersion());
  webClient.setAjaxController(new NicelyResynchronizingAjaxController());
}

代码示例来源:origin: stackoverflow.com

WebClient webClient = new WebClient(BrowserVersion.FIREFOX_24);
 webClient.getOptions().setJavaScriptEnabled(true);
 webClient.getOptions().setThrowExceptionOnScriptError(false);
 webClient.getOptions().setCssEnabled(false);
 webClient.setAjaxController(new NicelyResynchronizingAjaxController());

代码示例来源:origin: stackoverflow.com

WebClient webClient=new WebClient(BrowserVersion.FIREFOX_3_6);
webClient.setAjaxController(new NicelyResynchronizingAjaxController());
webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.waitForBackgroundJavaScript(50000);

代码示例来源:origin: com.github.albfernandez.test-jsf/jsf-test-scriptunit

private void setupWebClient() {
  webClient = new WebClient(browser);
  mockConnection = new MockWebConnection();
  webClient.setWebConnection(mockConnection);
  webClient.setAjaxController(new NicelyResynchronizingAjaxController());
}

代码示例来源:origin: org.apache.myfaces.extensions.cdi.test/myfaces-extcdi-cargo-support-module

/**
 * {@inheritDoc}
 */
@Override
//@Before
public void before()
{
  super.before();
  webClient = new WebClient(getBrowserVersion());
  webClient.setAjaxController(new NicelyResynchronizingAjaxController());
}

代码示例来源:origin: out0fmemory/GuozhongCrawler

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);
  }
}

代码示例来源:origin: stackoverflow.com

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);

代码示例来源:origin: stackoverflow.com

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);

代码示例来源:origin: stackoverflow.com

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);

代码示例来源:origin: stackoverflow.com

webClient.setThrowExceptionOnScriptError(false);
webClient.setJavaScriptEnabled(true);
webClient.setAjaxController(new NicelyResynchronizingAjaxController());
webClient.setJavaScriptTimeout(20000);
webClient.waitForBackgroundJavaScript(20000);

代码示例来源:origin: stackoverflow.com

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();

代码示例来源:origin: stackoverflow.com

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();

代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl

@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);
}

代码示例来源:origin: org.jboss.jsfunit/jboss-jsfunit-core

wcSpec.getProxyPort());
if (proxyHost == null) wc = new WebClient(wcSpec.getBrowserVersion());
wc.setAjaxController(new NicelyResynchronizingAjaxController());
wc.setWebConnection(new JSFUnitWebConnection(wc.getWebConnection()));
wcSpec.setWebClient(wc);

代码示例来源:origin: com.synaptix.redpepper/redpepper-automation

@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;
  }
}

代码示例来源:origin: timurstrekalov/saga

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;
}

相关文章

WebClient类方法