Data Driven Test - Protractor

322 views Asked by At

I want is to edit a profile details with passing data from a json file.

Data Form having:

-First Name
-Last Name
-Current Password
-New Password
-Confirm Password, etc....

I need to change only Last Name. How can I do?

--Edited--

"This is the form which I have to edit."

I need to change Only the Last name, First name should be the same. I'm passing values through json file.

[
  {
    "fname":"" ,
    "lname":"",
    "currentpassword":"",
    "newpassword":"",
    "confirmpassword":""
  }
]

And this is the code :

//import login details
var testData = require('./login_details.json');

//import editprofiledata
var editData = require('./editprofiledata.json');

describe ('Edit Profile Test', function(){

    //browser.driver.manage().window().maximize();
    browser.get("http://example");

    testData.forEach (function (data) {
        it ('Login to the system, and redirect to the dashboard', function() {
            element(by.name('email')).clear().sendKeys(data.Email);
            element(by.name('password')).clear().sendKeys(data.Password);

            //**click on Login button**//
            element(by.css('[ng-disabled="register.$invalid"]')).click();

            //**popup message click**//
            element(by.css('[ng-click="tapToast()"]')).click();
        });
    });

         it("redirect to the Edit Profile",function () {
            
             element(by.css('[ng-click="profileView()"]')).click();

             element(by.css('[ng-click = "goToEditView(2)"]')).click();

             browser.sleep(500);
         });

    editData.forEach (function (data) {
        it("changing details", function () {

            element(by.name('fname')).clear().sendKeys(data.fname);
            element(by.name('lname')).clear().sendKeys(data.lname);
            browser.sleep(1000);
            element(by.model('userEdit.currentPassword')).clear().sendKeys(data.currentpassword);
            browser.sleep(1000);
            element(by.model('userEdit.password')).clear().sendKeys(data.newpassword);
            browser.sleep(1000);
            element(by.model('userEdit.confirmPassword')).clear().sendKeys(data.confirmpassword);
            browser.sleep(1000);

element(by.css('[ng-click="editUserProfile(userEdit)"]')).click();
            browser.sleep(2000);
        });
    });
});

How can I do this?

1

There are 1 answers

2
mateusz sanko On

Not so clear question but I guess you are thinking about some data provider like:

jasmine-data-provider