如何解决这个e2e测试?

时间:2018-06-08 11:19:49

标签: javascript typescript protractor

问题是当你点击"添加规则"按钮,你得到新的"搜索术语"和"搜索textarea"领域。 但量角器无法看到它们。

 it('On "Add new Audience Rule" page should have two rules and two 
    search Terms', () => {
    audiencePage.addRule.click().then(() => {
        expect(audiencePage.ORbutton.isPresent()).toBe(true);
        expect(audiencePage.searchTerms.count()).toEqual(2);
    });
});

错误日志:

1) Audience page: On "Add new Audience Rule" page should have two rules and two search Terms
  - Expected false to be true.
  - Expected 1 to equal 2.

点击之前和之后的屏幕截图"添加规则" BTN: enter image description here

1 个答案:

答案 0 :(得分:1)

当你这样尝试时它会起作用吗?



beforeAll(() => {
    audiencePage.addRule.click();
});

it('On "Add new Audience Rule" page should have an OR button', () => {
    expect(audiencePage.ORbutton.isDisplayed()).toBe(true);
});

it('On "Add new Audience Rule" page should have two search Terms', () => {
    expect(audiencePage.searchTerms.count()).toEqual(2);
});