2017-04-06 7 views
-1

It JSON 파일에서 값을 입력 할 때 값이 웹 페이지에 정의되지 않은 것으로 표시됩니다. 어떤 생각입니까?그것은 JSON 파일에서 값을 입력 할 때 웹 페이지에서 값을 정의되지 않은 것으로 표시합니다. 어떤 생각입니까?

JSON 파일 :

[ 
    { 

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

] 

SPEC 파일 :

'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 파일 :

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 

}, 

} 

답변

1

,378에서파일의 경우 모든 데이터는 객체의 배열로 저장됩니다. 따라서 testdata1 변수의 데이터에 액세스하려면 testdata1[0].firstName과 같은 배열 색인을 지정해야합니다.