繁体   English   中英

Selenium RC 403错误 - 禁止代理

[英]Selenium RC 403 Error - Forbidden for proxy

我正在尝试在Snow Leopard上使用Java 6,JUnit 4和Eclipse运行Selenium RC 1.0.3。

这是我的测试类,来自Selenium文档:

public class TestCase extends SeleneseTestCase {

  @Before
  public void before() throws Exception {
    setUp("http://www.google.com/", "*firefox");
  }

  @Test
  public void test() {
    selenium.open("/");
    selenium.type("q", "selenium rc");
    selenium.click("btnG");
    selenium.waitForPageToLoad("30000");
    assertTrue(selenium.isTextPresent("Advanced search"));
  }
}

我收到以下错误,该错误发生在调用selenium.open()

11:16:59.916 INFO - Got result: 
XHR ERROR: URL = http://localhost:4444/ Response_Code = 403 
Error_Message = Forbidden+for+Proxy on session a8cf1e0bd5ed42c5a4df0c25ec5f5286

我已尝试(在网上找到各种建议)用*firefox *chrome*firefox替换*firefox ,用https替换http并添加selenium.start() ,但没有人帮助,甚至改变了行为。

有任何想法吗?

编辑: selenium-server正在运行,本地防火墙已禁用。

好的,这是一个解决方案,没有任何理解:如果@Before方法被删除,并且对setUp()的调用被移入@Test方法,那么它的工作原理如下:

@Test
public void test() throws Exception {
  setUp("http://www.google.com/", "*chrome");
  selenium.open("/");
  selenium.type("q", "selenium rc");
  selenium.click("btnG");
  selenium.waitForPageToLoad("30000");
  assertTrue(selenium.isTextPresent("Advanced search"));
}

但基于以下理解,这是一个更好的解决方案:

import com.thoughtworks.selenium.SeleneseTestCase;

public class TestCase extends SeleneseTestCase {

  public void setUp() throws Exception {
    setUp("http://www.google.com/", "*firefox");
  }

  public void testAuto() throws Exception {
    selenium.open("/");
    selenium.type("q", "selenium rc");
    selenium.click("btnG");
    selenium.waitForPageToLoad("30000");
    assertTrue(selenium.isTextPresent("Advanced search"));
  }
}

事实证明, SeleneseTestCase从JUnit 3扩展了TestCase 。我已经将文档示例升级到JUnit 4,而没有考虑可能导致的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM