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

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

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

WebClient.setCredentialsProvider介绍

[英]Sets the credentials provider that will provide authentication information when trying to access protected information on a web server. This information is required when the server is using Basic HTTP authentication, NTLM authentication, or Digest authentication.
[中]设置试图访问web服务器上受保护信息时提供身份验证信息的凭据提供程序。当服务器使用基本HTTP身份验证、NTLM身份验证或摘要身份验证时,需要此信息。

代码示例

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

/**
* Perform the initial request and provide Basic authentication 
* credentials when challenged.
*
* @param wcSpec The WebClient specification.
*
* @return The requested page if authentication passed.  Otherwise, return
*         the error page from the server (usually a 401 error).
*/
public Page doInitialRequest(WebClientSpec wcSpec) throws IOException
{
 wcSpec.getWebClient().setCredentialsProvider(this.credProvider);
 return super.doInitialRequest(wcSpec);
}

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

WebDriver driver = new HtmlUnitDriver() {

 @Override
 protected WebClient modifyWebClient(WebClient client) {
  // This class ships with HtmlUnit itself
  DefaultCredentialsProvider creds = new DefaultCredentialsProvider();

  // Set some example credentials
  creds.addCredentials("user", "selenium");

  // And now add the provider to the webClient instance
  client.setCredentialsProvider(creds);

  return client;
 }
};

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

WebDriver driver = new HtmlUnitDriver() {
  protected WebClient modifyWebClient(WebClient client) {
    // This class ships with HtmlUnit itself
    DefaultCredentialsProvider creds = new DefaultCredentialsProvider();

    // Set some example credentials
    creds.addCredentials("username", "password");

    // And now add the provider to the webClient instance
    client.setCredentialsProvider(creds);

    return client;
  }
};

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

WebDriver driver = new HtmlUnitDriver() {
  protected WebClient modifyWebClient(WebClient client) {
    DefaultCredentialsProvider creds = new DefaultCredentialsProvider();

    creds.addCredentials(username, password, hostname, port, realm);

    client.setCredentialsProvider(creds);
    return client;
  }
};

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

WebDriver driver = new HtmlUnitDriver() {
  protected WebClient modifyWebClient(WebClient client) {

    DefaultCredentialsProvider creds = new DefaultCredentialsProvider();
    // set the credentials
    creds.addCredentials("username", "password");

    // set the provider
    client.setCredentialsProvider(creds);

    return client;
  }
};

代码示例来源:origin: net.sourceforge.jwebunit/jwebunit-htmlunit-plugin

.getProxyHost(), getTestContext().getProxyPort(), AuthScope.ANY_REALM);
wc.setCredentialsProvider(creds);
wc.addWebWindowListener(new WebWindowListener() {
 @Override

相关文章

WebClient类方法