【问题标题】:Selenium HTTP ERROR: 403 Forbidden for ProxySelenium HTTP 错误:403 禁止代理
【发布时间】:2016-05-22 14:20:00
【问题描述】:

我在http://server:4440 启动并运行了一个 selenium 集线器,在 2 台不同的机器上,我在网格上注册的每台机器上都有一个节点,我可以在 /grid/console 中看到。

当我在PHPUnit Selenium2 测试中尝试连接到集线器时,我收到一个无活动会话错误。测试用例代码:

public static $browsers = array(
    array(
        'browserName'       => 'firefox',
        'host'              => 'my-jenkins',
        'port'              => 4440
    )
);

FWIW,这里是节点和集线器服务启动。 枢纽:

java -jar E:\selenium\selenium-server-standalone-2.50.1.jar -role hub -hubConfig E:\\selenium\hub.json

集线器配置文件:

{
"host": "my-jenkins",
"port": 4440,
"newSessionWaitTimeout": -1,
"servlets" : [],
"prioritizer": null,
"capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
"throwOnCapabilityNotPresent": true,
"nodePolling": 5000,
"cleanUpCycle": 5000,
"timeout": 300000,
"browserTimeout": 0,
"maxSession": 5,
"jettyMaxThreads":-1
}

节点:

java -jar E:\selenium\selenium-server-standalone-2.50.1.jar -role node -nodeConfig E:\selenium\node.json -hub http://my-jenkins:4440/grid/register -DfirefoxProfileTemplate=E:\selenium\firefox_profiles\selenium_tester -Dwebdriver.firefox.profile=selenium_tester -Dwebdriver.ie.driver=E:\selenium\IEDriverServer.exe

节点配置:

{
"capabilities":[
{
  "platform": "WINDOWS",
  "browserName": "firefox",
  "maxInstances": 1,
  "seleniumProtocol": "WebDriver"
},{
  "platform": "WINDOWS",
  "browserName": "internet explorer",
  "version": "11",
  "maxInstances": 1,
  "seleniumProtocol": "WebDriver"
},{
  "platform": "WINDOWS",
  "browserName": "internet explorer",
  "version": "10",
  "maxInstances": 1,
  "seleniumProtocol": "WebDriver"
},{
  "platform": "WINDOWS",
  "browserName": "internet explorer",
  "version": "9",
  "maxInstances": 1,
  "seleniumProtocol": "WebDriver"
}
],
"configuration":{
"maxSession":7,
"port":5556,
"register":true,
"registerCycle": 5000,
"nodeTimeout":120,
"nodePolling":2000,
"registerCycle":10000,
"cleanUpCycle":2000,
"timeout":30000
}
}

浏览到http://localhost:5556 时,我得到一个

403 Forbidden
Forbidden for Proxy

关于我在这里做错了什么有什么想法吗?

【问题讨论】:

    标签: selenium jenkins phpunit selenium-grid


    【解决方案1】:
    1. 停止您的集线器并检查其他进程是否使用此端口。 对于 Windows:

    Win + R >> run cmd >> netstat -aon | findstr :4440 最右列显示使用此端口的进程的 PID。

    或通过资源监视器。 Win + R >> 运行resmon >> 网络 >> 监听端口

    1. 在您的测试中,您应该与 hub 进行交互。我曾与Java 合作过,并且:

      WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4440/wd/hub"), capabilities)

    http://localhost:5556 - 这是一个节点。

    您应该通过集线器与您的节点进行交互: http://localhost:4440

    我尝试直接导航到我的工作环境中的一个节点并得到同样的错误。

    HTTP ERROR: 403
    
    Forbidden for Proxy
    RequestURI=/
    
    Powered by Jetty://
    

    来自Selenium documentation:

    Selenium-Grid 的工作原理——使用集线器和节点

    网格由一个集线器和一个或多个节点组成。两者都是使用 selenium-server.jar 可执行文件启动的。

    集线器接收要执行的测试以及有关应该运行测试的浏览器和“平台”(即 WINDOWS、LINUX 等)的信息。它“知道”已“注册”到集线器的每个节点的配置。使用此信息,它选择具有请求的浏览器平台组合的可用节点。一旦选择了一个节点,测试启动的 Selenium 命令就会发送到集线器,集线器会将它们传递给分配给该测试的节点。该节点运行浏览器,并在该浏览器中针对被测应用程序执行 Selenium 命令。

    【讨论】:

      猜你喜欢
      • 2011-02-23
      • 2015-11-18
      • 2011-07-12
      • 1970-01-01
      • 2018-01-14
      • 1970-01-01
      • 2018-11-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多