Skip to content

giozom/CodeceptDemo

Repository files navigation

A Codecept Example Using PHP Travel Website

You will need to install the following:

  • [sudo] npm install -g codeceptjs
  • [sudo] npm install -g webdriverio

Install and Start Selenium Webdriver Manager

  • npm install -g webdriver-manager
  • webdriver-manager update
  • webdriver-manager start

Run the tests (defined in package.json)

  • ~/CodeceptDemo $ npm test OR
  • ~/CodeceptDemo $ codeceptjs run --steps

Skipping Scenario

  • Add .skip flag to a scenario you wish to skip
  • Use Scenario.skip
  • For example:
Scenario.skip('Hotel Booking', (I, bookingPage) => {
    I.amOnPage('http://phptravels.net/hotels');
    I.seeInTitle('Hotels Listings');
    I.fillField(bookingPage.fields.location, 'Rendez');
    I.pressKey('Enter');
});

Running Specific Scenario

  • Add .only flag to a scenario you wish to run
  • Use Scenario.only
  • For example:
Scenario.only('Hotel Booking', (I, bookingPage) => {
    I.amOnPage('http://phptravels.net/hotels');
    I.seeInTitle('Hotels Listings');
    I.fillField(bookingPage.fields.location, 'Rendez');
    I.pressKey('Enter');
});

Running Specific Feature

  • You can add a '@wip' tag to a feature you only want to run.
  • For example:
'use strict';
Feature('@wip Book Hotel Accommodation');

Before((I) => {
    I.loginAs('demouser');
});

Scenario('Hotel Booking', (I, bookingPage) => {
    I.amOnPage('http://phptravels.net/hotels');
    I.seeInTitle('Hotels Listings');
    I.fillField(bookingPage.fields.location, 'Rendez');
    I.pressKey('Enter');

});
  • Notice the '@wip' tag in the feature above
  • To run this feature only from command line: npm run test:wip

WebDriverIO Helper

  • This Codecept Demo is using the WebDriverIO Helper as defined in the Codecept.json file
  • Location: ~/CodeceptDemo/codecept.json

Acceptance Test Configuration

  • Can have a collection of Page Objects to include when running your acceptance suite
  • See loginPage example ~/CodeceptDemo/conf/webdriverio/acceptance.conf.js

Screenshots

  • Screenshots are stored in the output folder

More About Codeceptjs

About

A Basic Codecept demo using WebDriverIO to test a travel site

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published