0

I used this quick start guide to install this test framework: https://github.com/codeception/codeceptjs/ .

After successful installation I edited my "mytest_test.js" with following additions:

Feature('CodeceptJS Demonstration');

Scenario('test some forms', (I) => {
  I.amOnPage('http://simple-form-bootstrap.plataformatec.com.br/documentation');
  I.fillField('Email', 'hello@world.com');
  I.fillField('Password', '123456');
  I.checkOption('Active');
  I.checkOption('Male');
  I.click('Create User');
  I.see('User is valid');
  I.dontSeeInCurrentUrl('/documentation');
});

Afterwards I started my test:

codeceptjs run --debug

My results are:

C:\laragon\www\codeceptjs2  (codeceptjs2@1.0.0) 31.01.2017 10:46:30,41                       
λ codeceptjs run --debug                                                                     
CodeceptJS v0.4.16                                                                           
Using test root "C:\laragon\www\codeceptjs2"                                                 

CodeceptJS Demonstration --                                                                  
 test some forms                                                                             
 > Error: Couldn't connect to selenium server                                                
 * I am on page "http://simple-form-bootstrap.plataformatec.com.br/documentation"            
 > Screenshot has been saved to C:\laragon\www\codeceptjs2\output\test_some_forms.failed.png 
 > Error: A session id is required for this command but wasn't found in the response payload 

I don't get any screenshots in the output folder and this framework doesn't work and I don't understand why.

package.json

{
  "name": "codeceptjs2",
  "version": "1.0.0",
  "description": "",
  "main": "mytest_test.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "codeceptjs": "^0.4.16",
    "selenium-webdriver": "^3.0.1",
    "webdriverio": "^4.6.2"
  }
}

codecept.json

{
  "tests": "./*_test.js",
  "timeout": 10000,
  "output": "./output",
  "helpers": {
    "WebDriverIO": {
      "url": "http://localhost",
      "browser": "firefox"
    }
  },
  "include": {
    "I": "./steps_file.js"
  },
  "bootstrap": false,
  "mocha": {},
  "name": "codeceptjs2"
}

steps_file.js

'use strict';
// in this file you can append custom step methods to 'I' object

module.exports = function() {
  return actor({

    // Define custom steps here, use 'this' to access default methods of I.
    // It is recommended to place a general 'login' function here.

  });
}
Meteor Newbie
  • 556
  • 1
  • 6
  • 22

3 Answers3

1

For a quickstart with CodeceptJs I would recommend you to use Nightmare helper. So in codecept.conf you should have something similar to this

'helpers': {
        'Nightmare': {
            'url': 'http://localhost:3000',
            'waitForTimeout': 10000,
            'show': false
        }
    },

And don't forget to install nightmare

 npm install --save-dev nightmare nightmare-upload
panagdu
  • 2,055
  • 1
  • 21
  • 35
  • I created a new folder and chose Nightmare with `codeceptjs init` command. Then, I installed nightmare with `npm install --save-dev nightmare`. In my package.json: `"nightmare": "^2.9.1"`. When I try to start my generated test file, I get instantly a Windows Script Host - Pop-up window with a compile error in Microsoft JScript. – Meteor Newbie Jan 31 '17 at 12:24
  • 1
    I installed Firefox and Google drivers for this framework and now everything works. Thanks for the hint with Nightmare. It running now after I installed following: `npm install -g nightmare nightmare-upload`. I will accept your answer and would appreciate if you could up vote my question. Someone down voted it without reason. – Meteor Newbie Jan 31 '17 at 13:42
0

Are you sure it was really set up properly? I think there should be an OK and check box after that first test. Maybe it did not successfully even go to google.com.

If that's not the problem, perhaps you can get it to output a screenshot, or use the codecept pause feature and inspect the state.

It is also possible that google saw your automated browser as a bot and did not send the same web page we see, so it actually sent a page without the #hplogo element.

Jason Livesay
  • 6,116
  • 3
  • 22
  • 30
  • I added my "codecept.json" and "steps_file.js" files. I tried `I.amOnPage('https://example.com/');I.see('Example Domain');`. But the result is still the same. It seems not to work and I don't understand why. I used the official quick guide for the default installation. Do you need more informations? Tell me please what information should I post. – Meteor Newbie Jan 30 '17 at 12:07
0

If you use the WebdriverIO helper, you need start you selenium server.

  1. npm install selenium-standalone -g
  2. selnium-standalone install
  3. selenium-standalone start

after that you can run it