``“使用本地功能时找不到newSession`

问题描述 投票:0回答:1

尝试使用BrowserStack本地功能时遇到此错误:

(node:67602) UnhandledPromiseRejectionWarning: UnsupportedOperationError: newSession: Not Found
    at parseHttpResponse (/Users/ardo/Documents/workspace/test-browser-stack/node_modules/selenium-webdriver/lib/http.js:578:11)
    at Executor.execute (/Users/ardo/Documents/workspace/test-browser-stack/node_modules/selenium-webdriver/lib/http.js:489:26)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:67602) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:67602) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:67602) UnhandledPromiseRejectionWarning: UnsupportedOperationError: newSession: Not Found
    at parseHttpResponse (/Users/ardo/Documents/workspace/test-browser-stack/node_modules/selenium-webdriver/lib/http.js:578:11)
    at Executor.execute (/Users/ardo/Documents/workspace/test-browser-stack/node_modules/selenium-webdriver/lib/http.js:489:26)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:67602) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)

我的代码很简单:

const webdriver = require('selenium-webdriver');
const browserstack = require('browserstack-local');

const runTestSuite = () => {
  const capabilities = {
    browserName: 'Chrome',
    browser_version: '80.0 beta',
    os: 'OS X',
    os_version: 'Catalina',
    resolution: '1024x768',
    'browserstack.user': '<user>',
    'browserstack.key': '<key>',
    'browserstack.local': true,
    'browserstack.localIdentifier': 'ardotest',
    // 'browserstack.use_w3c': true,
    acceptSslCerts: true,
    name: 'Bstack-[Node] Sample Test-OS X Catalina-Chrome 80',
  };

  // https://www.browserstack.com/question/663
  const driver = new webdriver.Builder()
    .usingServer('http://localhost:3000') // tried using the IP that I got from Network settings on my machine, it spat out the same error
    .withCapabilities(capabilities)
    .build();

  console.log('quit');
  driver.quit();
};

// creates an instance of Local
const bsLocal = new browserstack.Local();

// replace <browserstack-accesskey> with your key. You can also set an environment variable - "BROWSERSTACK_ACCESS_KEY".
const bsLocalArgs = { key: '<browserstack-accesskey>' };
// https://github.com/browserstack/browserstack-local-nodejs/blob/master/lib/Local.js

// starts the Local instance with the required arguments
bsLocal.start(bsLocalArgs, function(err) {
  if (err) {
    console.error(err);
    return;
  }

  if (!bsLocal.isRunning()) {
    return;
  }

  try {
    runTestSuite();
  } catch (e) {
    console.error(e);
  } finally {
    // stop the Local instance
    bsLocal.stop(function(err) {
      if (err) {
        console.error(err);
      }
      console.log('===== BrowserStack tunnel stopped =====');
    });
  }
});

版本:

    "selenium-webdriver": "^4.0.0-alpha.5",
    "browserstack-local": "^1.4.5",

我的本地环境:

    "node": "10.16.3",
    "npm": "6.8.0",

macOS 10.14.6

查看代码,很明显,它试图访问/session网址以创建新会话或其他内容。我不确定是否应该手动支持/session,或者我只是在这里缺少真正愚蠢的东西?

node.js selenium-webdriver browserstack
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.