Selenium HTTP ERROR:403 Forbidden for Proxy

时间:2016-02-11 17:03:09

标签: selenium jenkins phpunit selenium-grid

我在http://server:4440启动并运行了一个selenium hub,在两台不同的机器上,我在网格上注册了一个节点,我可以在/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

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

1 个答案:

答案 0 :(得分:0)

  1. 停止您的集线器并检查其他进程是否使用此端口。 对于Windows:
  2. Win + R>>运行cmd>> netstat -aon | findstr :4440最右边的列显示了使用此端口的进程的PID。

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

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

      WebDriver driver = new RemoteWebDriver(新网址(" http://localhost:4440/wd/hub"),功能)

    2. 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命令。

相关问题