Skip to content

Quickstart

Use WebDriver for classical Selenium setup

Section titled “Use WebDriver for classical Selenium setup”
This gives you access to rich Selenium ecosystem and cross-browser support for majority of browsers and devices.

Start with WebDriver »

WebDriver support is implemented via webdriverio library


Use TestCafe for cross-browser testing without Selenium

Section titled “Use TestCafe for cross-browser testing without Selenium”
TestCafe provides cross-browser support without Selenium. TestCafe tests are faster, require no extra tooling and faster than regular Selenium. However, can be less stable.

Start with TestCafe »


Use CodeceptJS all-in-one installer to get CodeceptJS, a demo project, and Playwright.

npx create-codeceptjs .

If you prefer not to use Playwright see other installation options.

Installation

To install codeceptjs into a different folder, like tests use npx create-codeceptjs tests

After CodeceptJS is installed, try running demo tests using this commands:

  • npm run codeceptjs:demo - executes demo tests in window mode
  • npm run codeceptjs:demo:headless - executes demo tests in headless mode
  • npm run codeceptjs:demo:ui - open CodeceptJS UI to list and run demo tests.

CodeceptJS UI application:


To start a new project initialize CodeceptJS to create main config file: codecept.conf.js.

npx codeceptjs init

Answer questions, agree on defaults:

QuestionDefault AnswerAlternative
Do you plan to write tests in TypeScript?n (No)or learn how to use TypeScript
Where are your tests located?**./*_test.jsor any glob pattern like **.spec.js
What helpers do you want to use?PlaywrightWhich helper to use for: web testing, mobile testing, API testing
Where should logs, screenshots, and reports to be stored?./outputpath to store artifacts and temporary files
Do you want to enable localization for tests?n English (no localization)or write localized tests in your language

Sample output:

? Do you plan to write tests in TypeScript? 'No'
? Where are your tests located? '**./*_test.js'
? What helpers do you want to use? 'Playwright'
? Where should logs, screenshots, and reports to be stored? '**./output**'
? Do you want to enable localization for tests? 'English (no localization)'

For Playwright helper provide a website to be tested and browser to be used:

QuestionDefault AnswerAlternative
Base url of site to be testedhttp://localhostBase URL of website you plan to test. Use http://github.com or sample checkout page if you just want to play around
Show browser windowy Yesor run browser in headless mode
Browser in which testing will be performedchromiumor run tests in firefox, webkit (which is opensource version of Safari) or launch electron app
? [Playwright] Base url of site to be tested 'http://mysite.com'
? [Playwright] Show browser window 'Yes'
? [Playwright] Browser in which testing will be performed. Possible options: chromium, firefox, webkit or electron 'chromium'

Create first feature and test when asked

Open a newly created file in your favorite JavaScript editor. The file should look like this:

Feature('My First Test');
Scenario('test something', ({ I }) => {
});

Write a simple test scenario:

Feature('My First Test');
Scenario('test something', ({ I }) => {
I.amOnPage('https://github.com');
I.see('GitHub');
});

Run a test:

npx codeceptjs run

The output should be similar to this:

Terminal window
My First Test --
test something
I am on page "https://github.com"
I see "GitHub"
OK

To quickly execute tests use following npm scripts:

After CodeceptJS is installed, try running demo tests using this commands:

  • npm run codeceptjs - executes tests in window mode
  • npm run codeceptjs:headless - executes tests in headless mode
  • npm run codeceptjs:ui - open CodeceptJS UI to list and run tests.

More commands available in CodeceptJS CLI runner.

▶ Next: CodeceptJS Basics

▶ Next: CodeceptJS with Playwright