Selenium NPM
​
JavaScript For Writing Selenium Test Scripts
​
Selenium JavaScript Installation And Setup
​
First Test In Selenium JavaScript
​
Concept Of MochaJS And ChaiJS In Selenium
​
Selenium Test In Mocha-Chai Framework
​
Page Object Model For Selenium In Mocha-Chai
​
Selenium Test In Mocha-Chai Framework
​
​
How To Write A Selenium Test In Mocha-Chai Framework ?
​
​
Prerequisites :
Install mocha-chai setup => Follow Guide
​
To construct a selenium test in mocha-chai framework follow these steps :
-
Open VS code,go to the File,click on Open folder.
-
Now browse to that project folder where setup has done for mocha-chai(In my case it's SeleniumJS.) to open it in editor.
-
Under the folder SeleniumJS,create a new folder as 'tests'.
-
Create a new .js file as 'Mocha_Chai_Test.js' within folder tests.
-
Use 'describe() ' function to structure a test suite.
-
Under the function 'describe() ',create multiple different-different test cases using the function 'it() '.
-
To run -
-
Navigate to the folder tests,
-
And then use command " npx mocha --no-timeouts 'filename.js' ", i.e. " npx mocha --no-timeouts 'Mocha_Chai_Test.js' ".
-
​
​
Creating a simple test using mocha-chai :
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
Output :
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
Creating test cases using mocha hooks :
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​​
​
​
​
​
​
​
​
​
Output :
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
Refer next page Page Object Model For Selenium In Mocha-Chai