I am new to Angular
and Protractor
. I have written couple of protractor test cases to automate registration, login and some other pages. To execute a test case for example student registration, I need to pass some data like name,dob,age,address etc, right now I hardcoded those values in my test cases which is not best practice so I want to externalize these input data values for all my protractor test cases. I have below thoughts around this but not able to decide which one is the best approach and industry standard.
- Keep input data in
JSON
file for each test set separately. - Keep all test sets input data in single
JSON
file. - Keep the test data in .js file read it from there.
please suggest me the best approach and any other best practices I should consider while writing protractor UI test cases as I am completely new to this framework.I am using protractor with jasmine 2.x
.
-Amar.
Yes. The data can be read from JSON file.
Step 1: Create a JSON file and add it into your project folder
{ "UserName":"uname@blah.com", "Password":"blahblah", }
Step 2: Import the file into your protractor.conf.js and assign it to params
Step 3: Access data in your test cases by referring the key values using ‘browser.params’ object
refer my blog for more information Data Driven Testing in Protractor Frameworks
POM Design Pattern in Protractor Frameworks
Configuring Explicit Waits in protractor E2E Framework - Best Practices