package com.vinod.test;
import java.io.BufferedReader;
import java.io.FileReader;
import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
public class TestApp10_WebdriverWithProxy {
public static void main(String[] args) throws Exception {
FileReader reader = new FileReader("rsrc/proxylist.txt");
BufferedReader in = new BufferedReader(reader);
String httpProxy;
while ((httpProxy = in.readLine()) != null) {
System.out.println("Using " + httpProxy);
FirefoxProfile profile = new FirefoxProfile();
Proxy proxy = new org.openqa.selenium.Proxy();
proxy.setHttpProxy(httpProxy);
profile.setProxyPreferences(proxy);
WebDriver driver = new FirefoxDriver(profile);
driver.get("http://bing.com");
Thread.sleep(1000);
driver.get("http://goo.gl/GfKGF");
Thread.sleep(2000);
driver.close();
}
}
}
No comments:
Post a Comment