Protractor 量角器W3C功能

Protractor 量角器W3C功能,protractor,desiredcapabilities,selenoid,webdriver-w3c-spec,Protractor,Desiredcapabilities,Selenoid,Webdriver W3c Spec,我正在使用含硒量角器。我需要使用停靠的Windows映像,这样我就可以从Linux框中测试Internet Explorer和Edge 我可以通过运行以下命令从curl开始工作: curl -X POST http://127.0.0.1:4444/wd/hub/session -d '{"capabilities":{"browserName":"MicrosoftEdge","count":1,"alwaysMatch":{"browserName":"MicrosoftEdge","sel

我正在使用含硒量角器。我需要使用停靠的Windows映像,这样我就可以从Linux框中测试Internet Explorer和Edge

我可以通过运行以下命令从curl开始工作:

curl -X POST http://127.0.0.1:4444/wd/hub/session -d '{"capabilities":{"browserName":"MicrosoftEdge","count":1,"alwaysMatch":{"browserName":"MicrosoftEdge","selenoid:options":{"enableVNC":true,"enableVideo":false,"enableLog":true,"logName":"edge-18.0.log"}}}}'
我的量角器配置如下所示:

  multiCapabilities: [
    {
      browserName: "MicrosoftEdge",
      "alwaysMatch": {
        browserName: "MicrosoftEdge",
        "selenoid:options": {
          enableVNC: true,
          enableVideo: false,
          enableLog: true,
          logName: "edge-18.0.log"
        }
      }
    }
  ]
但量角器通过赛璐珞服务器发送,如下所示:

{
    "desiredCapabilities": {
        "browserName": "MicrosoftEdge",
        "count": 1,
        "alwaysMatch": {
            "browserName": "MicrosoftEdge",
            "selenoid:options": {
                "enableVNC": true,
                "enableVideo": false,
                "enableLog": true,
                "logName": "edge-18.0.log"
            }
        }
    }
}
{
    "desiredCapabilities": {
        "browserName": "MicrosoftEdge",
        "version": "18.0",
        "enableVNC": true,
        "enableVideo": false,
        "count": 1
    },
    "capabilities": {
        "browserName": "MicrosoftEdge"
    }
}
  multiCapabilities: [{
    browserName: 'MicrosoftEdge',
    version: '18.0',
    enableVNC: true,
    enableVideo: false
  }]
问题是desiredCapabilities应该是“capabilities”。我一直在到处寻找,试图找出它是在哪里创建的,这样我就可以创建某种标志来切换它

有什么想法吗?

使用量角器6.0解决了我的问题,但打破了我所有的测试

通过修补SeleniumWebDriver包,我能够继续使用5.4.1。从量角器6的操作方式来看,我对量角器5.4.1进行了操作:

我编辑了位于节点_modules/selenium webdriver/lib/webdriver.js的文件,并添加了以下内容:

// Capability names that are defined in the W3C spec.
const W3C_CAPABILITY_NAMES = new Set([
    'acceptInsecureCerts',
    'browserName',
    'browserVersion',
    'platformName',
    'pageLoadStrategy',
    'proxy',
    'setWindowRect',
    'timeouts',
    'unhandledPromptBehavior',
]);
    let W3CCaps = new Capabilities(capabilities);
    for (let k of W3CCaps.keys()) {
      // Any key containing a colon is a vendor-prefixed capability.
      if (!(W3C_CAPABILITY_NAMES.has(k) || k.indexOf(':') >= 0)) {
        W3CCaps.delete(k);
      }
    }

    cmd.setParameter('capabilities', W3CCaps);
然后在同一个文件中,我修改了静态createSessionexecutor、capabilities、opt_flow、opt_onQuit方法,以添加以下内容:

// Capability names that are defined in the W3C spec.
const W3C_CAPABILITY_NAMES = new Set([
    'acceptInsecureCerts',
    'browserName',
    'browserVersion',
    'platformName',
    'pageLoadStrategy',
    'proxy',
    'setWindowRect',
    'timeouts',
    'unhandledPromptBehavior',
]);
    let W3CCaps = new Capabilities(capabilities);
    for (let k of W3CCaps.keys()) {
      // Any key containing a colon is a vendor-prefixed capability.
      if (!(W3C_CAPABILITY_NAMES.has(k) || k.indexOf(':') >= 0)) {
        W3CCaps.delete(k);
      }
    }

    cmd.setParameter('capabilities', W3CCaps);
在所有这些更改之后,请求获取Selenoid如下所示:

{
    "desiredCapabilities": {
        "browserName": "MicrosoftEdge",
        "count": 1,
        "alwaysMatch": {
            "browserName": "MicrosoftEdge",
            "selenoid:options": {
                "enableVNC": true,
                "enableVideo": false,
                "enableLog": true,
                "logName": "edge-18.0.log"
            }
        }
    }
}
{
    "desiredCapabilities": {
        "browserName": "MicrosoftEdge",
        "version": "18.0",
        "enableVNC": true,
        "enableVideo": false,
        "count": 1
    },
    "capabilities": {
        "browserName": "MicrosoftEdge"
    }
}
  multiCapabilities: [{
    browserName: 'MicrosoftEdge',
    version: '18.0',
    enableVNC: true,
    enableVideo: false
  }]
我的量角器5配置如下所示:

{
    "desiredCapabilities": {
        "browserName": "MicrosoftEdge",
        "count": 1,
        "alwaysMatch": {
            "browserName": "MicrosoftEdge",
            "selenoid:options": {
                "enableVNC": true,
                "enableVideo": false,
                "enableLog": true,
                "logName": "edge-18.0.log"
            }
        }
    }
}
{
    "desiredCapabilities": {
        "browserName": "MicrosoftEdge",
        "version": "18.0",
        "enableVNC": true,
        "enableVideo": false,
        "count": 1
    },
    "capabilities": {
        "browserName": "MicrosoftEdge"
    }
}
  multiCapabilities: [{
    browserName: 'MicrosoftEdge',
    version: '18.0',
    enableVNC: true,
    enableVideo: false
  }]
注:


因此,我不必担心刷新安装或更新,我使用包补丁包创建一个补丁,当这些事件发生时应用。下面是一段精彩的视频,介绍如何使用该软件包

似乎只有Gragorator 6.0.0完全支持w3c。你用的是最新版本吗?就在钱上。谢谢@vania poohKeep记住量角器6.0仍然是测试版,还不稳定