Skip to main content
Commonmark migration
Source Link

###For Protractor/JavaScript , use JSON for data driven testing.

For Protractor/JavaScript , use JSON for data driven testing.

###For Protractor/JavaScript , use JSON for data driven testing.

For Protractor/JavaScript , use JSON for data driven testing.

deleted 3 characters in body
Source Link
Vishal Aggarwal
  • 5.6k
  • 2
  • 20
  • 37

##For Protractor/JavaScript , use JSON for data driven testing.###For Protractor/JavaScript , use JSON for data driven testing.

##For Protractor/JavaScript , use JSON for data driven testing.

###For Protractor/JavaScript , use JSON for data driven testing.

added 550 characters in body
Source Link
Vishal Aggarwal
  • 5.6k
  • 2
  • 20
  • 37

JSON example:

{
[
    {"username":"User1", "password":"Password1"}, 
    {"username":"User2", "password":"Password2"}, 
    {"username":"User3", "password":"Password3"}
]
}

You may store data in a json file and simply read into a variable and use it as required:

var testData = require('../example/Test Data/Test.json');
    
    describe('LoginPage', function() {
    
    it("data.description", function () {
        browser.get("http://127.0.0.1:8080/#/login");
        element(by.model("username")).sendKeys(testData[0].username);
        element(by.model("password")).sendKeys(testData[0].passwordFieldpassword); 
        element(by.buttonText("Authenticate")).click();
 
   });
  });
 }); 

JSON example:

{
"employees":[
    {"firstName":"John", "lastName":"Doe"}, );
    {"firstName":"Anna", "lastName":"Smith" },);
    {"firstName":"Peter", "lastName":"Jones"}
]
}); 

You may store data in a json file and simply read into a variable and use it as required:

var testData = require('../example/Test Data/Test.json');

describe('LoginPage', function() {

it("data.description", function () {
    browser.get("http://127.0.0.1:8080/#/login");
    element(by.model("username")).sendKeys(testData[0].username);
    element(by.model("password")).sendKeys(testData[0].passwordField); 
    element(by.buttonText("Authenticate")).click();
 
   });
  });
 }); 

JSON example:

{
"employees":[
    {"firstName":"John", "lastName":"Doe"}, 
    {"firstName":"Anna", "lastName":"Smith"},
    {"firstName":"Peter", "lastName":"Jones"}
]
}

JSON example:

{
[
    {"username":"User1", "password":"Password1"}, 
    {"username":"User2", "password":"Password2"}, 
    {"username":"User3", "password":"Password3"}
]
}

You may store data in a json file and simply read into a variable and use it as required:

var testData = require('../example/Test Data/Test.json');
    
    describe('LoginPage', function() {
    
    it("data.description", function () {
        browser.get("http://127.0.0.1:8080/#/login");
        element(by.model("username")).sendKeys(testData[0].username);
        element(by.model("password")).sendKeys(testData[0].password); 
        element(by.buttonText("Authenticate")).click();
    
       });
      });
     }); 
added 550 characters in body
Source Link
Vishal Aggarwal
  • 5.6k
  • 2
  • 20
  • 37
Loading
deleted 26 characters in body
Source Link
Vishal Aggarwal
  • 5.6k
  • 2
  • 20
  • 37
Loading
added 1728 characters in body
Source Link
Vishal Aggarwal
  • 5.6k
  • 2
  • 20
  • 37
Loading
Source Link
Vishal Aggarwal
  • 5.6k
  • 2
  • 20
  • 37
Loading