量角器在预期发生之前执行afterEach

时间:2017-05-25 00:30:45

标签: javascript angular protractor

对于我的生活,我无法弄清楚为什么会这样。基本上是'它'测试正在运行并正确执行UNTIL期望,此时它立即跳出新页面并执行afterEach语句。我尝试过使用browser.wait,然后将afterEach添加到' it' browser.sleep等获得相同的结果。

那些对量角器有更多了解的人知道如何在运行afterEach之前强制它执行期望吗?

 afterEach(function() {
    browser.get(browser.params.urls.base).then(function() {
        $('a[href="/Account/LogOff"]').click();
    });
 });

it('Should use the access code url and login to the content', function() {
    loginPage.registerWithAccessCode();
    loginPage.accessCodeExisting(accessCode, browser.params.user.email, browser.params.user.password);
    loginPage.accessCodeSubmit();

    expect(browser.getCurrentUrl()).toContain('pal/placementtest/welcome');     
});

1 个答案:

答案 0 :(得分:0)

您是否将其包裹在describe

试试这个结构:

describe('My login scenario', function() {
  beforeEach(function() {
    loginPage.registerWithAccessCode();
    // the rest of your "act" steps...
  });

  it('should...', function() {
    expect(browser.getCurrentUrl()).toContain('pal/placementtest/welcome');
  });

  afterEach(function() {
    // Logout
  });
});
相关问题