Lets Learn Test Automation Tools : Learn CodeceptJS

Lets Learn Test Automation Tools : Learn CodeceptJS

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
        
No alt text provided for this image

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,

No alt text provided for this image


要查看或添加评论,请登录

Kushan Shalindra Amarasiri的更多文章

社区洞察

其他会员也浏览了