当前位置: 首页>>代码示例>>Java>>正文


Java BrowserVersion.BEST_SUPPORTED属性代码示例

本文整理汇总了Java中com.gargoylesoftware.htmlunit.BrowserVersion.BEST_SUPPORTED属性的典型用法代码示例。如果您正苦于以下问题:Java BrowserVersion.BEST_SUPPORTED属性的具体用法?Java BrowserVersion.BEST_SUPPORTED怎么用?Java BrowserVersion.BEST_SUPPORTED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.gargoylesoftware.htmlunit.BrowserVersion的用法示例。


在下文中一共展示了BrowserVersion.BEST_SUPPORTED属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createWebClient

/**
 * Creates a new web client.
 *
 * @return A new {@link WebClient} instance.
 */
public static WebClient createWebClient()
{
	WebClient webClient = new WebClient(BrowserVersion.BEST_SUPPORTED);
	webClient.getOptions().setThrowExceptionOnFailingStatusCode(true);
	webClient.getOptions().setThrowExceptionOnScriptError(false);
	return webClient;
}
 
开发者ID:sropelato,项目名称:Fetchino,代码行数:12,代码来源:Util.java

示例2: SessionLoginHelper

/**
 * 对于给定登录凭据,使用给定User-Agent和给定登录超时开始登录会话,且指定是否保持登录。
 * @param email E-Mail/ID/手机号
 * @param password 明文密码
 * @param userAgent User-Agent
 * @param keepLoggingIn 指定是否保持登录
 * @param loginTimeoutMillis 登录执行超时
 * @throws NetworkException 在出现网络问题时抛出
 * @throws IllegalArgumentException 在参数无效时抛出
 * @throws NullPointerException 在有参数为Null时抛出
 */
public SessionLoginHelper(@NotNull String email, @NotNull String password,
                          long loginTimeoutMillis, boolean keepLoggingIn, @NotNull String userAgent)
        throws BiliLiveException {
    this.email = email;
    this.password = password;
    this.loginTimeoutMillis = loginTimeoutMillis;
    this.keepLoggingIn = keepLoggingIn;
    checkArguments(userAgent);

    webClient = new WebClient(BrowserVersion.BEST_SUPPORTED/*, "127.0.0.1", 8888*/); // Commented code is for Fiddler Debugging.
    initWebClient(userAgent);
    startLogin();
}
 
开发者ID:cqjjjzr,项目名称:BiliLiveLib,代码行数:24,代码来源:SessionLoginHelper.java

示例3: createDriver

@Override
public WebDriver createDriver() throws Exception {
    final HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.BEST_SUPPORTED);
    driver.setJavascriptEnabled(true);
    manage(driver);
    return driver;
}
 
开发者ID:LearnLib,项目名称:alex,代码行数:7,代码来源:HtmlUnitDriverConfig.java

示例4: Browser

public Browser(String startpage, boolean echoPages) throws IOException {

        // Turn off annoying HTMLUnit logging
        java.util.logging.Logger.getLogger("com.gargoylesoftware").setLevel(Level.OFF);

        webclient = new WebClient(BrowserVersion.BEST_SUPPORTED);

        // Initialise browser settings
        webclient.getOptions().setJavaScriptEnabled(true);
        webclient.getOptions().setUseInsecureSSL(true);
        webclient.getCookieManager().setCookiesEnabled(true);

        this.gotoURL(startpage);
        
        this.echoPages = echoPages;
    }
 
开发者ID:felsenhower,项目名称:stine_calendar_bot,代码行数:16,代码来源:Browser.java

示例5: test

private void test(final HttpUrl baseUrl) throws Exception {
  final DefaultCredentialsProvider credentials = new DefaultCredentialsProvider();
  final WebClient web = new WebClient(BrowserVersion.BEST_SUPPORTED);
  web.setCredentialsProvider(credentials);
  try {
    final WebClientOptions options = web.getOptions();
    options.setThrowExceptionOnFailingStatusCode(false);
    options.setThrowExceptionOnScriptError(false);
    options.setJavaScriptEnabled(true);
    options.setCssEnabled(true);
    options.setDownloadImages(true);
    options.setRedirectEnabled(true);
    options.setUseInsecureSSL(true);

    final Page page1 = web.getPage(baseUrl.url());
    assertEquals(401, page1.getWebResponse().getStatusCode());
    assertWWWAuthHeaderIsCorrect(
      page1.getWebResponse().getResponseHeaderValue("WWW-AUTHENTICATE"),
      baseUrl.host()
    );

    credentials.addCredentials("anonymous", "anonymous",
                               baseUrl.host(), baseUrl.port(), "[email protected]" + baseUrl.host());

    final Page page2 = web.getPage(baseUrl.url());
    assertEquals(401, page2.getWebResponse().getStatusCode());
    assertWWWAuthHeaderIsCorrect(
      page2.getWebResponse().getResponseHeaderValue("WWW-AUTHENTICATE"),
      baseUrl.host()
    );

    credentials.removeCredentials(new AuthScope(baseUrl.host(), baseUrl.port()));
    credentials.addCredentials("user1", "password1",
                               baseUrl.host(), baseUrl.port(), "[email protected]" + baseUrl.host());

    final Page page3 = web.getPage(baseUrl.url());
    assertEquals(200, page3.getWebResponse().getStatusCode());

    credentials.removeCredentials(new AuthScope(baseUrl.host(), baseUrl.port()));
    credentials.addCredentials("user 2", "password 2",
                               baseUrl.host(), baseUrl.port(), "[email protected]" + baseUrl.host());

    final Page page4 = web.getPage(baseUrl.url());
    assertEquals(200, page4.getWebResponse().getStatusCode());
  }
  finally {
    web.close();
  }
}
 
开发者ID:programingjd,项目名称:okserver,代码行数:49,代码来源:DigestAuthHandlerTest.java

示例6: testWeb

static void testWeb(final String baseUrl) throws Exception {
  final File root = getWebRoot();
  //try { Thread.sleep(3000L); } catch (final InterruptedException ignore) {}
  final WebClient web = new WebClient(BrowserVersion.BEST_SUPPORTED);
  try {
    web.setCache(new Cache() {
      @Override
      protected boolean isCacheableContent(WebResponse response) {
        return true;
      }
    });
    final WebClientOptions options = web.getOptions();
    options.setThrowExceptionOnFailingStatusCode(false);
    options.setThrowExceptionOnScriptError(false);
    options.setJavaScriptEnabled(true);
    options.setCssEnabled(true);
    options.setDownloadImages(true);
    options.setRedirectEnabled(false);
    options.setUseInsecureSSL(true);

    final HtmlPage page = web.getPage(baseUrl);
    assertEquals(200, page.getWebResponse().getStatusCode());
    final Cache cache = web.getCache();
    assertEquals(3, cache.getSize());
    final WebResponse imgResponse = cache.getCachedResponse(req(baseUrl + "img.png"));
    assertEquals(200, imgResponse.getStatusCode());
    assertEquals(new File(root, "img.png").length(), imgResponse.getContentLength());
    final WebResponse jsResponse = cache.getCachedResponse(req(baseUrl + "script.js"));
    assertEquals(200, jsResponse.getStatusCode());
    assertEquals(text(new File(root, "script.js")), jsResponse.getContentAsString().trim());
    final WebResponse htmlResponse = cache.getCachedResponse(req(baseUrl));
    assertEquals(200, htmlResponse.getStatusCode());
    assertEquals(text(new File(root, "index.html")), htmlResponse.getContentAsString().trim());

    cache.clear();
    web.getPage(baseUrl + "index.html");
    assertEquals(1, cache.getSize());
    final WebResponse indexResponse = cache.getCachedResponse(req(baseUrl + "index.html"));
    assertEquals(301, indexResponse.getStatusCode());
    assertEquals(baseUrl, indexResponse.getResponseHeaderValue("Location"));
  }
  finally {
    web.close();
  }
}
 
开发者ID:programingjd,项目名称:okserver,代码行数:45,代码来源:FileHandlerTest.java

示例7: SuapConnection

public SuapConnection(String matricula, String senha) throws Exception {

        //this.removeHtmlUnitWarnings();
        
        conn = new WebClient(BrowserVersion.BEST_SUPPORTED);
        conn.getOptions().setJavaScriptEnabled(false);
        conn.getOptions().setCssEnabled(false);
        conn.getOptions().setAppletEnabled(false);

        this.matricula = matricula;
        this.senha = senha;

    }
 
开发者ID:marcocspc,项目名称:SUAPPasswordResetter,代码行数:13,代码来源:SuapConnection.java


注:本文中的com.gargoylesoftware.htmlunit.BrowserVersion.BEST_SUPPORTED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。