【问题标题】:How to make Selenium pick my .pac file?如何让 Selenium 选择我的 .pac 文件?
【发布时间】:2011-09-06 10:20:23
【问题描述】:

我在 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();
 }
}

【问题讨论】:

    标签: java firefox selenium proxy pac


    【解决方案1】:

    这个问题背后的主要目标是在 Windows 环境中的 Firefox 中运行 Selenium 测试。我有一个解决方法。我打开了 Internet Explorer 并转到 Internet 选项并转到连接并在那里设置自动 .pac 配置。答对了!成功了。

    【讨论】:

      猜你喜欢
      • 2018-06-23
      • 2019-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-18
      • 2016-06-28
      • 1970-01-01
      相关资源
      最近更新 更多