量角器测试没有完成,似乎循环直到茉莉花超时错误命中

Protractor test does not finish, seems to loop until the jasmine timeout error hits

无法使最基本的量角器测试正常工作,我感到很愚蠢。给定量角器 5.4.1 我有一个 spec.js

describe('my example tests', () => {
  const EC = protractor.ExpectedConditions;
    it('tests google', async () => {
      await browser.waitForAngularEnabled(false);
      await browser.get("https://google.com");
      await browser.wait(EC.visibilityOf($('input')));
      await element(by.css("input")).click();});});

的会议
exports.config = {

  directConnect: true,
  specs: ['tests/**/*.js'],
  capabilities: {
    browserName: 'chrome',
  },

  SELENIUM_PROMISE_MANAGER: false,

  jasmineNodeOpts: {
    defaultTimeoutInterval: 40000
  }
};

当 运行 protractor conf.js 浏览器打开时,转到该页面,然后直到 40 秒茉莉花超时命中才没有任何反应。我得到的是每秒约 25 次警告
W/element - more than one element found for locator By(css selector, input) - the first result will be used
好像某个命令是 运行 无限循环,直到我收到一个错误 Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. ,它告诉我的不多而且很难 google.

有人遇到过这个问题吗?

在 Google 页面上,定位器 $('input') 匹配许多元素,这就是您收到警告的原因。第一个用了,可惜,第一个被隐藏了。所以 await browser.wait(EC.visibilityOf($('input'))); 失败,导致超时错误。 使用在页面上定位唯一且未隐藏的输入元素的定位器,例如 element(by.name('q')) 应该会更好。

我喜欢 Hetzner cloud protractor test helper,它提供了像 waitToBeDisplayed 这样的包装器,如果我没记错的话(我已经有一段时间没用过了),它的错误报告不太通用。