Selenium RC 403 错误 - 禁止代理

发布于 2024-09-02 16:55:14 字数 1047 浏览 0 评论 0原文

我正在尝试在 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,将 http 替换为 https 并添加selenium.start(),但没有任何帮助,甚至改变了行为。

有什么想法吗?

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

I'm trying to run Selenium RC 1.0.3 using Java 6, JUnit 4, and Eclipse on Snow Leopard.

Here is my test class, from the Selenium docs:

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"));
  }
}

I receive the following error, which occurs at the time that selenium.open() is called:

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

I've tried (finding various suggestions on the web) replacing *firefox with *chrome or *firefox, replacing http with https and adding selenium.start(), but none have helped, or even changed the behavior.

Any ideas?

EDIT: The selenium-server is running, and the local firewall is disabled.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

︶葆Ⅱㄣ 2024-09-09 16:55:14

好的,这是一个解决方案,无需任何理解:如果删除 @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 时没有考虑可能会导致什么问题。

OK, here's a solution, without any understanding: If the @Before method is removed, and the call to setUp() is moved into the @Test method, then it works:

@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"));
}

But here is a better solution, based on understanding:

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"));
  }
}

It turns out that SeleneseTestCase extends TestCase from JUnit 3. I had upgraded the documentation example to JUnit 4 without thinking about what problems may be caused.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文