Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何让Selenium选择我的.pac文件?_Java_Firefox_Selenium_Proxy_Pac - Fatal编程技术网

Java 如何让Selenium选择我的.pac文件?

Java 如何让Selenium选择我的.pac文件?,java,firefox,selenium,proxy,pac,Java,Firefox,Selenium,Proxy,Pac,我在Firefox中使用Foxyproxy,每当我想切换到我的沙盒环境时,我都会使用一个.pac文件。生活是美好的 但当我尝试使用基于浏览器的测试工具(如Selenium)实现自动化时,我无法让它通过我的Sandbox.pac代理。如何实现?我正在使用JUnit。这是我的示例代码 import org.openqa.selenium.server.RemoteControlConfiguration; import org.openqa.selenium.server.SeleniumServe

我在Firefox中使用Foxyproxy,每当我想切换到我的沙盒环境时,我都会使用一个.pac文件。生活是美好的

但当我尝试使用基于浏览器的测试工具(如Selenium)实现自动化时,我无法让它通过我的Sandbox.pac代理。如何实现?我正在使用JUnit。这是我的示例代码

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.setSingleWindow(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();
 }
}

这个问题背后的主要目的是在windows环境下在Firefox中运行Selenium测试。我为此做了一番努力。我打开了一个Internet浏览器,转到Internet选项,转到连接,并在那里设置自动.pac配置。答对 了成功了