How to read data from EXCEL file using Jasmine (Protractor framework)

12,490 views
Skip to first unread message

Nakul Arora

unread,
Nov 4, 2014, 3:43:06 AM11/4/14
to ang...@googlegroups.com

We are new to Protractor and Jasmine.  We are trying to automate E2E testing of Angular application using Protractor and Jasmine. As part of the test data input we would like the script to read the data from an excel file (*.xls, *.xlsx). But I am unable to find any reference to this information. I really appreciate if anyone can give the exact approach to read data from excel as an input to the automation script.

Cheers

Please note : Only reason I am posting a standard snippet is bcoz we are actually trying to get the input as excel for this specific script (as our learning curve). Appreciate all the help. Thank you.

Sample Code:

describe('Test Calculator', function() {
var firstNumber = element(by.model('first'));

var secondNumber = element(by.model('second'));

var goButton = element(by.id('gobutton'));

function ReadDataFromExcel() {

    // Code to read first number & second number from Excel;

  };

  it('Testcase 1', function() {

        browser.get('http://juliemr.github.io/protractor-demo/');

        // ReadDataFromExcel()
        // for each record in EXCEL; perform below operation;
        // {
            firstNumber.sendKeys(a);
            secondNumber.sendKeys(b);
            goButton.click();
            // Always perform '+' operation
        // }

     });

});

Lucian Enache

unread,
Nov 4, 2014, 3:47:49 AM11/4/14
to ang...@googlegroups.com
Why would you even try to do something loke that? Your tests should be data agnostic, but at modt if you really want to provide data from the outside, use either a web service or some static files that deliver JSON format data.

Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Nakul Arora

unread,
Nov 4, 2014, 4:53:02 AM11/4/14
to ang...@googlegroups.com
Actually i wanna try to make it data driven framework, so if you have any idea to get data from excel sheet using java script then please share it.

Adrian Lynch

unread,
Nov 4, 2014, 5:02:16 AM11/4/14
to ang...@googlegroups.com
You're running this in node?

Grab yourself a node package and go from there:


Adrian

--

Nakul Arora

unread,
Nov 5, 2014, 11:52:54 PM11/5/14
to ang...@googlegroups.com
Thanks Adrian, Its really very use-full. but i am not able to use these files because I don't know how to use these file.
could you please guide me?


On Tuesday, November 4, 2014 2:13:06 PM UTC+5:30, Nakul Arora wrote:

David Souther

unread,
Nov 6, 2014, 8:52:27 AM11/6/14
to ang...@googlegroups.com
An overview of NodeJS is likely outside the scope of this mailing list. Message me directly and I can give you some pointers - davidsouther...@gmail.com
Message has been deleted

Manoj

unread,
Nov 27, 2014, 2:58:09 AM11/27/14
to ang...@googlegroups.com
Use XLSX to read and write data. working.
https://www.npmjs.org/package/xlsx

Arshdeep Brar

unread,
Mar 10, 2015, 11:32:16 AM3/10/15
to ang...@googlegroups.com
Hey Nakul, did you get something to work? As am also very new and want to know if it is possible as we do in Selenium and QTP.

Peter Hendrick

unread,
Aug 21, 2015, 8:42:26 PM8/21/15
to AngularJS
Hi, I'm not sure if you were able to figure this out or not. however, I was able to acomplish just this. If you start with an xls file, you will have to convert it to .json format. There are websites and applications that will do this for you. Just google .xls to .json. Then you will need to place the json in your test code. 

Here's what your json might look like.

[
    {
        "someId": "signInButton",
        "sendSomeKeys": "j...@j.com"
    },
    {
        "someId": "passwordButton",
        "sendSomeKeys": "password"
    }
]

And here's how to implement it in your test:

'use strict';

var testData = require('./path/to/json.json');

describe('your test', function() {
    testData.forEach( function (data) {
        it('should read from an external json', function(){
            element(by.id(data.someId)).sendKeys(data.sendSomeKeys);
        });
    });
});

Swati Khandelwal

unread,
Dec 2, 2015, 2:36:02 AM12/2/15
to AngularJS
Hi Peter,

Your code was really very helpful. But I have a query related to it. Please explain the usage of parameter 'data'. I mean from where the value of data would come. The above code works perfectly on my system but i am unable to analyze the 'data' parameter.
Please help!

Balaji Singh .Y

unread,
Aug 4, 2016, 8:03:49 AM8/4/16
to AngularJS

Manaswini choudhary

unread,
Nov 24, 2016, 5:07:36 AM11/24/16
to Angular
Hi peter,

    could you pelase tell me where we need to place the json file?and also what are all the configuration changes we need to make for this data driven frame work.????

Shivakumar H N

unread,
Feb 21, 2017, 9:10:23 AM2/21/17
to Angular and AngularJS discussion
Getting the Uncaught ReferenceError: require is not defined - whether there a way to resolve the require not defined in jasmine?


On Saturday, 22 August 2015 06:12:26 UTC+5:30, Peter Hendrick wrote:

Balaji Singh .Y

unread,
Feb 24, 2017, 11:24:08 AM2/24/17
to ang...@googlegroups.com
Hi All,

Even i was very much frustuated with datadriven framework with protractor and jasmine. Initially i was using Json file as object repository and for data also i was using the json file only.

After lot of search on Internet and other forums i just got tired nothing worked out their is no much info on datadriven with excel.

That`s when i started designing my framework on datadriven with excel and succesfully impleted it.

But the only issue is i cant make it run my testcase with different set of data.

even though with lot of try with different possiblites it didn`t work out but it works with one to one mapping that is each test case with datarow in excel.

so if u need my apporach please let me know and contact my on this email id : bal...@gmail.com

With Regards,
Balaji Singh
Mobile No : +91 8884479958

--
You received this message because you are subscribed to a topic in the Google Groups "Angular and AngularJS discussion" group.

To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/szvTofhwp1M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+unsubscribe@googlegroups.com.

To post to this group, send email to ang...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
BALAJI SINGH .Y

jyotsn...@gmail.com

unread,
Aug 29, 2017, 7:09:49 AM8/29/17
to Angular and AngularJS discussion, balaj...@gmail.com
Hi Balaji,

                Can you help me out with this question.How do you test the data that is added today by data driven using protractor?Can you reply me as soon as possible.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.

To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.



--
BALAJI SINGH .Y

Ranjith Samalla

unread,
Apr 18, 2018, 9:17:49 AM4/18/18
to Angular and AngularJS discussion
HI


I'm also facing issue how to work with excel sheet for protractor


On Tuesday, November 4, 2014 at 2:13:06 PM UTC+5:30, Nakul Arora wrote:

Tito

unread,
Apr 18, 2018, 3:36:08 PM4/18/18
to Angular and AngularJS discussion
why are you using excel at all? why not make it data driven?

Ranjith Samalla

unread,
Apr 19, 2018, 12:50:43 AM4/19/18
to ang...@googlegroups.com
Hi Tito,

for now I shown demo to management through Json files just i'm passing data to test script but now Managment asking instead of Json can you try with excel sheet so i.e reason I'm posting Question here

here I'm new to Protractor even I dont know how to use Data driven testing  plz guide me which once is better and how can I use for that i can explain to management 

Thanks & Regards,
Ranjith Samalla
9440247045



--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe@googlegroups.com.

Tito

unread,
Apr 19, 2018, 12:59:07 AM4/19/18
to Angular and AngularJS discussion
well it depends
1. what kind of date is it
2. how much data is it
3. who is populating this data inyo excel
4. is it being populated manually or is it generated automatically from yet another data spirce

Ranjith Samalla

unread,
Apr 19, 2018, 2:08:14 AM4/19/18
to ang...@googlegroups.com
No

for now i'm only one person doing testing and i only need to enter data manually etc..

Thanks & Regards,
Ranjith Samalla
9440247045



Tito

unread,
Apr 19, 2018, 8:43:11 AM4/19/18
to Angular and AngularJS discussion
well you could try databases such as
mysql
postgres
sql server

and have your test use that instead of excel

Ranjith Samalla

unread,
Apr 20, 2018, 1:37:40 AM4/20/18
to ang...@googlegroups.com
For Test Data ex: +ve and -ve how we can you do using mysql etc..?



Thanks & Regards,
Ranjith Samalla
9440247045



Tito

unread,
Apr 20, 2018, 3:05:57 PM4/20/18
to Angular and AngularJS discussion
it does not matter what type of test you are doing. what was included in the excel spreadsheet.
can you show us some of the data you were leveraging in excel to do your test


On Thursday, April 19, 2018 at 10:37:40 PM UTC-7, Ranjith Samalla wrote:
For Test Data ex: +ve and -ve how we can you do using mysql etc..?



Thanks & Regards,
Ranjith Samalla
9440247045



On Thu, Apr 19, 2018 at 6:13 PM, Tito <yos...@gmail.com> wrote:
well you could try databases such as
mysql
postgres
sql server

and have your test use that instead of excel

--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.

Ranjith Samalla

unread,
Apr 25, 2018, 1:09:05 AM4/25/18
to ang...@googlegroups.com
hi tito,


ex: UserNmae field: accepting 1 to 20 alphanumaric data only
for this +ve and - ve testing like this i want to do

Thanks & Regards,
Ranjith Samalla
9440247045



To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe@googlegroups.com.

Tito

unread,
Apr 25, 2018, 6:32:41 AM4/25/18
to Angular and AngularJS discussion
and then what happens? how is the data processed. the more info you provide the quicker we might provide you a data driven solution.
how does the test process this data

spruh...@gmail.com

unread,
May 25, 2018, 2:22:37 PM5/25/18
to Angular and AngularJS discussion
Hi Balaji,
I also want to know abt how to read the data (test data) by using XLXS report,Kindly help me for this.



Thanks 
Spruha
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.

To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.



--
BALAJI SINGH .Y

nikhil rao

unread,
Jun 13, 2019, 5:04:27 AM6/13/19
to Angular and AngularJS discussion
Reply all
Reply to author
Forward
0 new messages