How to add proxy setting to webdriver

I had to run the Webdriver scripts on a Firefox and I had to use a particular proxy to get access to the QA/Dev environment. Here is the code that you can use to change the proxy settings.

FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("network.proxy.type", 1);
firefoxProfile.setPreference("network.proxy.http", "");
firefoxProfile.setPreference("network.proxy.http_port", 80);
firefoxProfile.setPreference("network.proxy.ssl", "");
firefoxProfile.setPreference("network.proxy.ssl_port", 80);
firefoxProfile.setPreference("network.proxy.no_proxies_on", "");
driver = new FirefoxDriver(firefoxProfile);

Make changes to the PROXY_HOST – “” and the PROXY_PORT – 80. The PROXY_PORT is an Integer and PROXY_HOST is a String.

The constructor DefaultSelenium(String, String, String, String) is undefined

I was creating a script in Java and wanted to run the script using TestNG and Eclipse. I was getting the following error when running the script.
The constructor DefaultSelenium(String, String, String, String) is undefined
To solve the issue you will have to make change to the setUp method.
My code was something like this selenium = new DefaultSelenium(“localhost”, “4444”, “*iexplore”, “”); having 4444 as a string. I then changed the code to selenium = new DefaultSelenium(“localhost”, 4444, “*iexplore”, “”);

Sample Selenium RC Script using TestNG Eclipse

Here is a sample Selenium RC TestNG script that you can use to create selenium scripts in java and debug or run the test scripts using TestNG.
Before you do that you will have to add the TestNG Eclipse plugin; Please have a look at the details given below:
You can download TestNG here.

For the Eclipse plug-in, we suggest using the update site:

* Select Help / Software updates / Find and Install.
* Search for new features to install.
* New remote site.
* For Eclipse 3.4 and above, enter
* For Eclipse 3.3 and below, enter
* Make sure the check box next to URL is checked and click Next.
* Eclipse will then guide you through the process.

However, should this method fail, you can also download the TestNG Eclipse plug-in directly and extract it in your dropins/ directory.

import com.thoughtworks.selenium.*;
import org.testng.annotations.*;
import static org.testng.Assert.*;

public class GoogleSearchTestNG {
public Selenium selenium;
public void setUp() throws Exception {
selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "");

public void testUntitled() throws Exception {"/");
selenium.type("q", "");"btnG");

public void tearDown() throws Exception {