1

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

1 に答える 1

0

この質問の背後にある主な目的は、Windows環境のFirefoxでSeleniumテストを実行することでした。私はこれを回避しました。Internet Explorerを開き、インターネットオプションに移動し、接続に移動して、そこで自動.pac構成を設定しました。ビンゴ!機能した。

于 2011-09-07T12:11:31.367 に答える