Lets Learn Test Automation Tools : Learn CodeceptJS
Kushan Shalindra Amarasiri
Director Quality Engineering at Social Catfish
CodeceptJS is an awesome test automation library implemented using JavaScript and its freely available for anyone to use. To use CodeceptJS, first we need to install NodeJS and we can install NodeJS version 14 onwards.
Once installed, run the following command to install CodeceptJS on your system.
npx create-codeceptjs .
It will start downloading and install the needed files to start CodeceptJS test automation.
To start with a new project run the following command which gives an awesome interactive menu which allows use the automation driver to do test automation. This helps us to create the CodeceptJS config file. I selected WebDriver
npx codeceptjs init
Next we need to create a ChromeDriver service as I have selected to run my scripts on Chrome.
To install Selenium standalone server run the following npm command
npm install selenium-standalone -g
Next run the following command to start the Selenium standalone server.
selenium-standalone install && selenium-standalone start
Open us the test script in the you favourite JavaScript editor and start scripting the following code.
Feature('login');
Scenario('Guru99 Login', ({ I }) => {
? ?I.amOnPage('https://demo.guru99.com/v4/');
I.fillField('uid', 'mgr123');
I.fillField('password', 'mgr!23');
I.forceClick('LOGIN');
I.see('mgr123');
});
Then to run the script, execute the following command
npm run codeceptjs
The automation code will get executed in the Chrome browser and the command window will show the status of the test,