2017-04-06 1 views
-1

Es zeigt den Wert als undefiniert in der Webseite, wenn ich Wert aus der JSON-Datei eingeben, Irgendeine Idee?Es zeigt den Wert als undefiniert in der Webseite, wenn ich Wert aus der JSON-Datei eingeben, Irgendeine Idee?

JSON-Datei:

[ 
    { 

    "firstName":"1233232322", 
    "lastName":"ramakrishnan", 
    "email":"[email protected]", 
    "password":"secondmay1991", 
    "confirmPassword":"secondmay1991" 
    } 

] 

SPEC DATEI:

'use strict'; 

browser.ignoreSynchronization = true; 

var testdata1 = require('./testdata1.json'); 

describe("Test the inksoft.com create an account page", function() { 
it("enter the account details", function() { 
    browser.get("https://qa.inksoft.com/EGT"); 
    browser.ignoreSynchronization = true; 
    browser.sleep(15000); 
    element(by.xpath("//a[text()='Create Account']")).click(); 
    browser.sleep(20000); 
    element(by.xpath("//input[@name='firstName']")).sendKeys(testdata1.firstName); 
    element(by.xpath("//input[@name='lastName']")).sendKeys(testdata1.lastName); 
    element(by.xpath("//input[@name='email']")).sendKeys(testdata1.email); 
    element(by.xpath("//input[@name='password']")).sendKeys(testdata1.password); 
    element(by.xpath("//input[@name='confirmPassword']")).sendKeys(testdata1.confirmassword); 
    element(by.xpath("//input[@type='submit']")).click(); 
    }); 
}); 

CONF DATEI:

exports.config = { 

//The address of a running selenium server. 

seleniumAddress: 'http://localhost:4444/wd/hub', 

//Here we specify the name of the specs files. 

framework: 'jasmine', 

specs: ['inksoftdata.js'], 

jasmineNodeOpts: { 

    showColors: true, 

    includeStackTrace: true, 

    defaultTimeoutInterval: 1440000 

}, 

} 

Antwort

1

In testdata1.json Datei werden alle Daten als ein Array von Objekten gespeichert. Um auf die Daten von testdata1 zuzugreifen, müssen Sie den Array-Index wie testdata1[0].firstName angeben.

Verwandte Themen