【问题标题】:Protractor - Get selenium node the test is running onProtractor - 获取运行测试的 selenium 节点
【发布时间】:2016-04-14 14:16:07
【问题描述】:

我正在使用量角器进行一些端到端测试。我们希望根据我们正在运行的 selenium 节点执行一组操作,以避免某些测试在同时运行时相互干扰。我如何才能获得我的 selenium hub 分配给我的测试运行的 selenium 节点?

通过重复问题的可能解决方案,我尝试了以下操作,看看 testsession api 会给我什么

browser.getSession().then(function (session) {
    var hub = "http://localhost:4444"; //IP or hostname of GRID

    var url = hub + "/grid/api/testsession?session=" + session.getId();
    console.log(url);
});

然后当我的测试运行时,我会从打印出来的浏览器中手动点击 url

http://localhost:4444/grid/api/testsession?session=17e14d0e-38da-4269-b23c-3b2d52569383

但是我得到的回应是

{"success":false,"msg":"Cannot find test slot running session 8ca57382-d7d8-44ae-b3bc-8c1223c86805 in the registry."}

我现在应该以不同的方式进行会话吗?

【问题讨论】:

  • 我没有否决您的问题,但它与this 重复。 Google 硒网格获取节点ID
  • @MikeJRamsey56 出于某种原因这不起作用。将用我到目前为止所做的事情更新我的问题
  • 你看第二个答案了吗?
  • 是的,这就是我到目前为止获得代码的方式。似乎返回的会话不是节点的任何会话,因为当我执行 localhost:4444/wd/hub/static/resource/hub.html 时,我看到那里的会话是 '08de5d7d-980d-472c-89e5-d06ef6d158a5'
  • var runOptions = new RemoteRunnerOptions(); var sessionId = runOptions.getSessionId();我在看here

标签: selenium protractor


【解决方案1】:

因此,我的代码 sn-p 也可以帮助其他人找到解决方案

browser.driver.getCapabilities().then(function (capabilities) {
        var hub = "http://localhost:4444"; //IP or hostname of GRID

        var url = hub + "/grid/api/testsession?session=" + capabilities.caps_['webdriver.remote.sessionid'];

        var res = request('GET', url);
        var testSession = JSON.parse(res.getBody().toString());
        var URL = new urlParse(testSession.proxyId);
        console.log(URL.host);
    });

【讨论】:

    猜你喜欢
    • 2016-11-10
    • 1970-01-01
    • 1970-01-01
    • 2021-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-21
    相关资源
    最近更新 更多