How to make Selenium pick my .pac file?
I am using Foxyproxy in Firefox and whenever I want to switch to my sandbox environment I use a .pac file. Life is good.
But when I try to automate using a browser based testing utility like Selenium, I am not able to make it go through my Sandbox .pac proxy. How to achieve it ? I am using JUnit. Here is my sample code.
import org.openqa.selenium.server.RemoteControlConfiguration;
import org.openqa.selenium.server.SeleniumServer;
import com.thoughtworks.selenium.*;
public class TestCase1 extends SeleneseTestCase {
Selenium selenium;
public static final String MAX_WAIT_TIME_IN_MS = "60000";
private SeleniumServer seleniumServer;
public void setUp() throws Exception {
RemoteControlConfiguration rc = new RemoteControlConfiguration();
rc.s开发者_运维百科etSingleWindow(true);
seleniumServer = new SeleniumServer(rc);
selenium = new DefaultSelenium("localhost", 4444, "*firefox",
"https://mywebsite.com/");
seleniumServer.start();
selenium.start();
}
public void testLogin() {
selenium.open("/");
selenium.type("id=user_name", "test");
selenium.type("id=password", "test");
selenium.click("css=input.btn");
selenium.waitForPageToLoad("30000");
assertTrue(selenium.isTextPresent("Signed in successfully"));
}
public void tearDown() throws InterruptedException {
selenium.stop();
seleniumServer.stop();
}
}
The main objective behind this question was to Run Selenium test in Firefox in a windows environment. I had a work around for this. I opened up an Internet Explore and went to Internet Options and went to connections and set the automatic .pac configuration there. Bingo! it worked.
精彩评论