条件登录在beforeAll - 量角器

时间:2016-07-11 17:26:20

标签: selenium protractor

寻找一个可重复的模式,将条件逻辑放在Protractor规范的beforeAll语句中。这是我到目前为止所得到的:

beforeAll(function () {

login.devTestLogin();

//Check to see if depedent service is up. If its down, log
customerManagement.resultCount.isPresent().then(function (result) {
    if (result) {
        console.log("Dependent Service - up");
        customerManagement.clickManageCustomer(0);
    } else {
        console.log('Dependent Service - down');
        process.exit(0);
    }
  });
});

这是我不断收到的错误消息:

[13:25:10] E/launcher - BUG: launcher exited with 1 tasks remaining
>> 
Warning: Tests failed, protractor exited with code: 100 Use --force to continue.

Aborted due to warnings.

Process finished with exit code 100

有没有人有一个好的可重复模式来执行测试/不测试逻辑?

1 个答案:

答案 0 :(得分:1)

您不使用beforeAll()。你将it()调用包装在if语句中。

describe('App', () => {

    customerManagement.resultCount.isPresent().then((present: boolean) => {
      if(present) {
          it('should do some stuff', () => {
            browser.get('/whatever')
              // add some more thenes here
              .then(result => expect(result).toContain('Some stuff'));
          });
      }
    });
});
相关问题