乐趣区

关于测试工具:0319-分布式测试Selenium-Grid

简介

Selenium Grid 近程运行 Selenium test,宗旨是在多个机器上并行运行 selenium

长处

  • 它是所有测试的核心入口点
  • 能够治理和管制浏览器运行的 Nodes/ 环境
  • 扩大
  • 并行运行测试
  • 跨平台测试
  • 负载平衡

组成

装置与应用

环境筹备:

  • java 环境
  • 浏览器对应的 webdriver

下载地址:

https://www.selenium.dev/down…

官网文档:

https://github.com/SeleniumHQ…

启动 selenium grid:

# 作为 hub 角色启动
java -jar selenium-server-standalone-<version>.jar -role hub

配置 node.json,此文件可治理分布式环境,样例如下:

{
  "capabilities":
  [
    {
      "browserName": "firefox",
      "marionette": true,
      "maxInstances": 5,
      "seleniumProtocol": "WebDriver"
    },
    {
      "browserName": "chrome",
      "maxInstances": 5,
      "seleniumProtocol": "WebDriver"
    },
    {
      "browserName": "internet explorer",
      "platform": "WINDOWS",
      "maxInstances": 1,
      "seleniumProtocol": "WebDriver"
    },
    {
      "browserName": "safari",
      "technologyPreview": false,
      "platform": "MAC",
      "maxInstances": 1,
      "seleniumProtocol": "WebDriver"
    }
  ],
  "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
  "maxSession": 5,
  "port": -1,
  "register": true,
  "registerCycle": 5000,
  "hub": "http://localhost:4444",
  "nodeStatusCheckTimeout": 5000,
  "nodePolling": 5000,
  "role": "node",
  "unregisterIfStillDownAfter": 60000,
  "downPollingLimit": 2,
  "debug": false,
  "servlets" : [],
  "withoutServlets": [],
  "custom": {}}

应用配置文件运行 selenium grid:

java -jar selenium-server-standalone.jar -role node -nodeConfig nodeconfig.json
退出移动版