0

I'm new to codeceptJS but best I can tell it simply does not work with yield.

'use strict';
Feature('Testing Begins');
Before((I) => {
  I.resizeWindow(1500, 1000);
  I.amOnPage('http://absolutenet.com');
});

Scenario('ANI testing', function*(I){
  I.waitForText('bring your site to life');
  I.amOnPage('http://www.absolutenet.com/');
  let title = yield I.grabTitle();
  console.info(title);
  I.see('bogus text that is not there');
});

I have tried several of the grab commands as well as executeScript. I know the commands are working because for some reason one or two lines do execute after the yield so I can output the variable I am assigning. However, I can never use it because the browser closes and the script terminates. Even worse, I can put in a test that is obviously invalid (I.see('some bogus non existent text');) and the Scenario exits with a Success!

The above is live so you can execute it to see the problem. Testing with Linux and FireFox if that matters.

Can anyone give me an example of how to use yield and continue the test?

UPDATE: The developer says this is a bug and it will be fixed soon.

Adrian Lynch
  • 8,237
  • 2
  • 32
  • 40
Tim Duncklee
  • 1,420
  • 1
  • 23
  • 35
  • Which test runner are you using with WebdriverIO? Are you using mocha or WebdriverIO's built-in wdio runner? – jrader Jan 12 '16 at 23:50
  • I'm not quite sure how to answer the question. This is codeceptJS not codeception. I believe codeceptJS is the test runner. – Tim Duncklee Jan 12 '16 at 23:52

1 Answers1

2

I see the following in the CodeceptJS readme:

With CodeceptJS your scenario-driven functional and acceptance tests will be as simple and clean as they can be. You don't need to worry about asynchronous nature of NodeJS or about various APIs of Selenium, PhantomJS, Protractor, etc, as CodeceptJS unifies them and makes them work as they were synchronous.

So you shouldn't need yield to run the test. CodeceptJS is a wrapper around WebdriverIO which takes care of those asynchronous tasks for you. You should be able to do the following :

Scenario('ANI testing', function*(I){
  I.waitForText('bring your site to life');
  I.amOnPage('http://www.absolutenet.com/');
  I.seeInTitle('my page title');
});

http://codecept.io/basics/

Though, for the sake of attempting to answer your question more thoroughly, codeceptJS has a great example for using generators :

Scenario('use page title', function*(I) {
  // ...
  var password = yield I.grabTextFrom('#password');
  I.fillField('password', password);
});

http://codecept.io/acceptance/

jrader
  • 670
  • 1
  • 5
  • 15
  • Absolutely your code will work. However, I believe you missed the part where grabbers do not work. I MUST be able to grab data from elements as well as return information from executeScript. There are instances where I have to use JavaScript to calculate a result and check to see if it is correct. This cannot be done without yield and yield crashes the script. I only used I.grabTitle() as a simple example that demonstrates the bug. – Tim Duncklee Jan 13 '16 at 00:38
  • The developer says this is a bug. I've updated the question. Pretty serious bug as it has stopped us in our tracks... :( – Tim Duncklee Jan 13 '16 at 00:40