Intern Selenium error: BUG: suiteEnd was received for invalid session

Intern Selenium error: BUG: suiteEnd was received for invalid session

我正在尝试通过 运行 无头 Chrome 浏览器进行测试来使用 Intern 4 进行功能测试。我相信一切都设置正确,并且最近为 Mac 终端安装了 selenium-server-standalone。我在尝试 运行 测试时得到以下结果:

Running "exec:test_functional" (exec) task
Listening on localhost:9000 (ws 9001)
Tunnel started
BUG: suiteEnd was received for invalid session 
(ノಠ益ಠ)ノ彡┻━┻
UnknownError: [POST http://localhost:4444/wd/hub/session / {"desiredCapabilities":{"name":"intern","idle-timeout":60,"browserName":"chrome","goog:chromeOptions":{"args":["headless","disable-gpu"]}}}] Cannot define class using reflection
  at Server.post  <tests/node_modules/src/Server.ts:367:14>
  at Server.createSession  <tests/node_modules/src/Server.ts:412:14>
  at Suite.before  <tests/src/lib/executors/Node.ts:469:8>
  at <tests/src/lib/Suite.ts:388:19>
  at new Task  <tests/node_modules/@dojo/core/async/Task.ts:239:3>
  at runLifecycleMethod  <tests/src/lib/Suite.ts:355:10>
  at before  <tests/src/lib/Suite.ts:458:10>
  at Suite.run  <tests/src/lib/Suite.ts:477:6>
  at <tests/src/lib/executors/Node.ts:821:20>
  at FunctionQueue.next  <tests/src/lib/executors/Node.ts:945:16>

TOTAL: tested 0 platforms, 0 passed, 0 failed; fatal error occurred
>> Exited with code: 1.
>> Error executing child process: Error: Process exited with code 1.
Warning: Task "exec:test_functional" failed. Use --force to continue.

Aborted due to warnings.

我运行正在使用最新版本的 Node、npm 和 Intern

解决此问题的任何帮助表示赞赏

编辑:

app.ts

// tests/functional/app.ts
const { suite, before, test } = intern.getPlugin("interface.tdd");
const { expect, assert } = intern.getPlugin("chai");

suite("app", () => {
  before(({ remote }) => {
    return remote
      .get("src/app.html")
      .setFindTimeout(5000)
      .findDisplayedByCssSelector("body");
  });

  let windowHandles: any;

  test("testing", ({ remote }) => {
    return remote
      // Click login button
      .findByClassName('hero-cta')
      .click()
      .end()

      // Switch to login window
      .getAllWindowHandles()
      .then(function(handles: string[]){
        windowHandles = handles;
        assert.isArray(windowHandles);
        return remote.switchToWindow(windowHandles[1]);
      })

      // Input user credentials and submit
      .findById('user_username')
      .type('username')
      .end()
      .findById('user_password')
      .type('password')
      .findAllByCssSelector('button')
      .click()
      .end()

      //Switch to app
      .getAllWindowHandles()
      .then(function(handles: string[]){
        assert.isArray(handles);
        return remote.switchToWindow(windowHandles[0]);
      })

      .find('css selector','span')
      .getVisibleText()
      .then(function(text: string) {
        console.log(text);
      })
  });
});

intern.json

{
...

"environments": [
    {
      "browserName": "chrome",
      "goog:chromeOptions": {
        "args": ["headless", "disable-gpu"]
      }
    }
  ]
}

当您系统上的 Java 版本对于 Selenium(为 Intern 管理 WebDriver 连接)来说太新时,会发生 Cannot define class using reflection 错误。硒需要 Java 1.8;当 Java 10 或 11 是默认值时,您会收到该错误。

另请注意,实习生测试不需要 selenium-server-standalone;默认情况下,实习生自行下载 Selenium 和所需的 WebDriver 隧道,并启动和关闭自己的 Selenium 实例。