【问题标题】:Protractor: Disabling the control flow量角器:禁用控制流
【发布时间】:2017-07-14 19:38:02
【问题描述】:

我听说 webdriver 控制流将来会被删除,并且想更新我的测试用例。

我不确定替换它的更好方法是什么:

  • 异步等待:运行良好,但 jshint 不支持。
  • promises 链接:我不知道如何确保 promise 与 jasmin 链接。

例如:

it('should should clear qa cookies using the qa command', function() {
    browser.waitForAngularEnabled(false)
    .then(browser.get('cookies url'));
});

it('should open product page', function() {
    browser.waitForAngularEnabled(true)
    .then(browser.get('page-url'))
    .then(browser.wait(function() {
        return element.all(by.css('locator')).first().isDisplayed();
    }))
    .then(expect(true).toBe(true));
});

如何使第二个规范仅在第一个规范之后运行?

谢谢!!!

【问题讨论】:

    标签: promise protractor control-flow


    【解决方案1】:

    我仍然建议使用 async/await。当您需要处理页面对象、保存一些数据以备将来使用等等时,就会出现问题。

    如果您的 jshint 出错,请考虑 TypeScript + TSlint

    【讨论】:

    • 感谢您的回答。我切换到 EsLint。
    【解决方案2】:

    你需要'return'和干净的视图箭头功能

    it('should should clear qa cookies using the qa command', function() {
         return browser.waitForAngularEnabled(false)
           .then(() => browser.get('cookies url'));
    });
    
    it('should open product page', function() {
         return browser.waitForAngularEnabled(true)
           .then(() =>browser.get('page-url'))
          .then(() =>browser.wait(() => element.all(by.css('locator')).first().isDisplayed()))
           .then(() => expect(true).toBe(true));
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-10-15
      • 2019-07-05
      • 2018-12-31
      • 2014-08-25
      • 2013-11-25
      • 1970-01-01
      • 2016-06-23
      相关资源
      最近更新 更多