0

I'm developing a testing suite and the only way I have found to be sure a page is ready, is when the selector 'div.spinner' disappear. I was able to do catch this condition with CapserJs (with PhantomJs or SlimerJs):

casper.waitWhileSelector('div.spinner');

I had to switch to codeceptjs 1.0.1 with nightmarejs 2.10.1 and I can't translate this condition properly.

I must avoid waiting some predefined amount of times as we have many environments to test, and depending on the load the waiting time can vary from 1s to 40s+.

Currently I'm planning to replicate on codecept the casper feature Casper.prototype.waitWhileSelector

Does anyone had a similar problem? Am I missing some feature in CodeceptJs?

Related github issue

Thanks in advance

sabau
  • 141
  • 1
  • 10

1 Answers1

0

For reference, this method was merged with the name waitUntilExists:

https://github.com/Codeception/CodeceptJS/pull/683 https://github.com/Codeception/CodeceptJS/issues/682

To use it you can do something like:

describe('#waitUntilExists', () => {  
  it('should wait for an element to be removed from DOM', () => {
    return I.amOnPage('/spinner')
      .then(() => I.seeElementInDOM('.loader'))
      .then(() => I.waitUntilExists('.loader'))
      .then(() => I.dontSeeElement('.loader'))
  });

  it('should wait for a non-exising element to be removed from DOM', () => {
    return I.amOnPage('/spinner')
      .then(() => I.dontSeeElement('.non-existing-class'))
      .then(() => I.waitUntilExists('.non-existing-class'))
      .then(() => I.dontSeeElement('.non-existing-class'))
  });
});
sabau
  • 141
  • 1
  • 10