I would like to know how can I authenticate on Proxy automaticaly using Selenium WebDriver.

I already could set my host and port using FirefoxProfile, but I could not set my proxy user and password.

Afterwards, I have made a research on web and I got this code:

package org.openqa.selenium.example;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

import com.gargoylesoftware.htmlunit.DefaultCredentialsPr ovider;
import com.gargoylesoftware.htmlunit.WebClient;

public class Script_001 {

static String PROXY_USER = "prog17";
static String PROXY_PASS = "045278";
static String PROXY_HOST = "ironport";
static int PROXY_PORT= 80;
static String PROXY_WORKSTATION = "tavo-notebook.";

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

// Configurações da proxy

// And now add the provider to the webClient instance

return client;

private DefaultCredentialsProvider DefaultCredentialsProvider() {
// TODO Auto-generated method stub
return null;


// And now use this to visit Google
//driver.manage().timeouts().implicitlyWait(90, TimeUnit.SECONDS);

// Find the text input element by its name
WebElement element = driver.findElement(By.name("q"));

// Enter something to search for
element.sendKeys("LUGATI IT Services");

// Now submit the form. WebDriver will find the form for us from the element

// Check the title of the page
System.out.println("Page title is: " + driver.getTitle());

public static void main(String[] args) throws Exception {
Script_001 script = new Script_001();

Does anyone knows how to get there?