As we all
are aware, data-driven testing is one of the important aspects we need to take
care of while designing any testing framework. There could be different approaches
to Data-Driven Testing like
- Reading Test Data from a properties file
- Reading Test Data from JSON File
- Reading Test Data from excel
We already
have seen in another blog, how to read data from a properties file and use it in
our automation framework. Please refer to this link to know about it.
In this
blog, we will learn how to read data from JSON File and use them in our
protractor automation test.
Before
proceeding further to this blog, I assume you have basic knowledge about
protractor and how to find XPath and execute protractor automation tests.
For this purpose lets first create one JSON file in our project lets name it as object.json
In this JSON
File I will store my Application URL along with few data locator
Please Note
that JSON file will always store data in Key-value pair inside { } braces for
e.g “ElementName”:”Xpath”
Below is sample JSON File
Below is sample JSON File
Now to Read
data from this JSON File inside our automation script we need to provide the
path of this JSON File using require and then we can read data from this JSON File using JSONfileName.ElementName and can
execute our automation script
Below is my runner class to execute this automation scripts
Thank you for the information Ankur. It's really informative, appreciate your efforts. Good Job!
ReplyOn the off chance that the identifiers of the two rooms are unique, open their regular entryway and bring together their identifiers and furthermore their rundowns. ExcelR Data Science Courses
ReplyExcellent Blog! I would like to thank for the efforts you have made in writing this post. I am hoping the same best work from you in the future as well. I wanted to thank you for this websites! Thanks for sharing. Great websites!
ReplyExcelR data science course in mumbai
no working E/launcher - Error: Error: Cannot find module '../Data/testdata.json'
ReplyRequire stack:
- C:\Users\hemas\Documents\Protractor TypeScript\JSFile\stepDefination\steps.js
- C:\Users\hemas\Documents\Protractor TypeScript\node_modules\cucumber\lib\cli\index.js
- C:\Users\hemas\Documents\Protractor TypeScript\node_modules\cucumber\lib\index.js
- C:\Users\hemas\Documents\Protractor TypeScript\node_modules\protractor-cucumber-framework\lib\cucumberLoader.js
- C:\Users\hemas\Documents\Protractor TypeScript\node_modules\protractor-cucumber-framework\index.js
- C:\Users\hemas\Documents\Protractor TypeScript\node_modules\protractor\built\runner.js
- C:\Users\hemas\Documents\Protractor TypeScript\node_modules\protractor\built\launcher.js
- C:\Users\hemas\Documents\Protractor TypeScript\node_modules\protractor\built\cli.js
- C:\Users\hemas\Documents\Protractor TypeScript\node_modules\protractor\bin\protractor
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
at Function.Module._load (internal/modules/cjs/loader.js:687:27)
at Module.require (internal/modules/cjs/loader.js:849:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object. (C:\Users\hemas\Documents\Protractor TypeScript\stepDefination\steps.ts:11:14)
at Module._compile (internal/modules/cjs/loader.js:956:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
at Module.load (internal/modules/cjs/loader.js:812:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Module.require (internal/modules/cjs/loader.js:849:19)
at require (internal/modules/cjs/helpers.js:74:18)
at C:\Users\hemas\Documents\Protractor TypeScript\node_modules\cucumber\lib\cli\index.js:119:42
at Array.forEach ()
at Cli.getSupportCodeLibrary (C:\Users\hemas\Documents\Protractor TypeScript\node_modules\cucumber\lib\cli\index.js:119:22)
at Cli.run (C:\Users\hemas\Documents\Protractor TypeScript\node_modules\cucumber\lib\cli\index.js:141:37)
[16:00:39] E/launcher - Process exited with error code 100
npm ERR! code ELIFECYCLE
npm ERR! errno 100
npm ERR! protractor-typescript@1.0.0 cucumbertest: `protractor JSFile/cucumberconfig.js`
npm ERR! Exit status 100
npm ERR!
npm ERR! Failed at the protractor-typescript@1.0.0 cucumbertest script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\hemas\AppData\Roaming\npm-cache\_logs\2020-04-29T10_30
This is a great article thanks for sharing this informative information. I will visit your blog regularly for some latest post. I will visit your blog regularly for Some latest post. buy instagram spread likes cheap
ReplySuch a very useful article. Very interesting to read this article. I would like to thank you for the efforts you had made for writing this awesome article.
ReplyData Science Course in Pune
Data Science Training in Pune
Thanks for such a great post and the review, I am totally impressed! Keep stuff like this coming.
ReplyData Science Institute in Bangalore
Really nice and interesting post. I was looking for this kind of information and enjoyed reading this one.
ReplyData Science Certification in Bangalore
You actually make it look so easy with your performance but I find this matter to be actually something which I think I would never comprehend. It seems too complicated and extremely broad for me. I'm looking forward for your next post, I’ll try to get the hang of it!
ReplyData Science Course in Bangalore
I have express a few of the articles on your website now, and I really like your style of blogging. I added it to my favorite’s blog site list and will be checking back soon…
ReplyData Science Training in Bangalore
I feel very grateful that I read this. It is very helpful and very informative and I really learned a lot from it.
ReplyData Analytics Course in Pune
Data Analytics Training in Pune
I am impressed by the information that you have on this blog. It shows how well you understand this subject.
ReplyBusiness Analytics Course in Pune
Business Analytics Training in Pune
I am impressed by the information that you have on this blog. Thanks for Sharing
ReplyEthical Hacking in Bangalore
Thanks for sharing great information. I like your blog and highly recommend. We also offer best data science training in Hyderabaddata scientist courses
ReplyI truly appreciate essentially perusing the entirety of your weblogs. Basically needed to advise you that you have individuals like me who value your work. Certainly an extraordinary post. Caps off to you! The data that you have given is useful.
Reply360DigiTG supply chain analytics beginner's guide
Wonderful blog found to be very impressive to come across such an awesome blog. I should really appreciate the blogger for the efforts they have put in to develop such an amazing content for all the curious readers who are very keen of being updated across every corner. Ultimately, this is an awesome experience for the readers. Anyways, thanks a lot and keep sharing the content in future too.
Reply360DigiTMG Tableau Course
Very nice blogs!!! i have to learning for lot of information for this sites…Sharing for wonderful information.Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing, data sciecne course in hyderabad
ReplyI have to search sites with relevant information ,This is a
Replywonderful blog,These type of blog keeps the users interest in
the website, i am impressed. thank you.
Data Science Course in Bangalore
I have to search sites with relevant information ,This is a
Replywonderful blog,These type of blog keeps the users interest in
the website, i am impressed. thank you.
Data Science Training in Bangalore
The blog you shared is very good. I expect more information from you like this blog. Thank you.
Replywhat is overloading
important libraries in python
substring function in python
data science linear regression in python
j2ee interview questions
python operator overloading
This is really useful information. I am satisfied with reading your blog.
Replyhow to learn java easily
cross platform mobile app development
successful social media campaigns
what is microsoft azure
tableau interview questions and answers
This is a splendid website! I"m extremely content with the remarks!ExcelR Data Analytics Course
ReplyIts a great pleasure reading your post.Its full of information I am looking for and I love to post a comment that "The content of your post is awesome" Great work.Best Data Science Courses in Hyderabad
ReplyThis is the best explanation for this title and keep updating here...
ReplyOpenspan Online Training
Openspan Online Course
Matlab Training in Chennai
Leadership Training in Chennai