Protractor tests , Jasmine and asynchronous solution

纵饮孤独 提交于 2019-12-11 14:25:57

问题


I using in my work protractor with jasmine . What found annoying and disturbing is ways I have to write always tests. I really don't like to do this waitsFor for promise from getCssValue. Can someone can show me better solution for asynchronous tests then this. At moment using Jasmine 2.0"

 describe('And I see a “Burger Menu” option on the  Header section', function () {
it('And the Left Hand Navigation is not visible When I access a Burger menu option on the ' +
'Header section Then I want to see the Left Hand Navigation menu', function () {
  runs(function () {
    Homepage.burger.click();
  });

  waits(500);

  runs(function () {
    Homepage.leftHandNav.getCssValue('display').then(function (item) {
      displayStatus = item;
    });
  });

  waitsFor(function () {
    return displayStatus;
  }, 200);

  runs(function () {
    expect(displayStatus).toBe('block');
  });
});

It seems like very complicated code for such functionality.


回答1:


Have you tried this?

expect(Homepage.leftHandNav.getCssValue('display')).toBe('block');

With the most recent versions it looks like working.

AFAIK expect waits internally for the related promises.



来源:https://stackoverflow.com/questions/23118703/protractor-tests-jasmine-and-asynchronous-solution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!