Protractor: problems with making scenarios

Before that day I always made isolated small tests. But now I want run them in one scenario. And I have the strange error. Some tests can't work together. For example. First one:

beforeEach(function(){
    browser.get('ng-components/examples/ps-grid-column-filter-range.html');
});

it('балун содержит текст', function () {
    filter_field.click();
    browser.actions().click(filter_field).perform();

browser.wait(function () {
  return balloon_info.isPresent();
     },5000).then(function () {
       expect(balloon_text.getText()).toContain(balloon_contain_text);
       expect(balloon_text.isDisplayed()).toBe(true);
  }).thenCatch(function () {
      expect(true).toBe(false);
 });
console.log("ps-grid-column-filter-range_spec_1.1.с");
});

Second one:

  beforeEach(function(){
    browser.get('ng-components/examples/ps-grid-column-filter-range.html');
 });

it('балун демонстрируется', function () {
    filter_field.click();
    browser.actions().click(filter_field).perform();

    browser.wait(function () {
      return balloon_info.isPresent();
      },5000).then(function () {
        expect(balloon_info.isDisplayed()).toBe(true);
    }
    ,function (error) {
       expect(false).toBe(true);
   });

console.log("ps-grid-column-filter-range_spec_1.1.a");
  });

When my tests isolated they working fine. But in group - they failing. What is my mistake? It is a problem with asynchronous?

Also, what is interesting is that some broken test hasn't method wait() in it.

Upvotes: 2

Views: 167

Answers (1)

Arno_Geismar
Arno_Geismar

Reputation: 2330

browser.wait is non blocking so your second test probably runs while your first is still in progress. And since it is the same functionality they probably influence each others outcome. Try putting them both in the same test and chain them with

.then()

You can make protractor blocking wait by following this example

Blocking wait

Upvotes: 1

Related Questions