cellsData
在全局变量中有如下数组
[ { id: 2,
cellId: 'R2C3',
row: '2',
col: '3',
value: '202',
rawValue: '202.0',
numValue: '$202' },
{ id: 3,
cellId: 'R2C4',
row: '2',
col: '4',
value: '2034',
rawValue: '2034.0',
numValue: '$2,034' }]
我有一个苏打水脚本,我想在从这个数组读取后验证数据问题是它在cellsData[startRowId].numValue
as, 27 undefined上给出错误
我也试过global.cellsData
但没有工作
错误
.keyYears 表 tbody tr:nth-child('+i+') td:nth-child(3)',''+ cellsData[startRowI ^
TypeError:无法读取未定义的属性“27”
var browser = soda.createClient({
.....
});
// Retrieving data from Excel sheet
testsheet.setAuth( 'user', 'pass', function(err){
if (err) console.log(err);
testsheet.getCells( 1, function(err, cellsObj){
if (err) console.log(err);
cellsData = cellsObj.cells;
rowcount = cellsObj.RowCount;
});
})
browser
.chain
.session()
.setSpeed(speed)
.setTimeout(2000)
.open('/')
.and(login('dev@dev.com', 'x1212GQsdtpS'))
.and(verifyData())
.end(function(err){
console.log('error');
});
function login(user, pass) {
return function(browser) {
browser
.click('css=a#loginButton')
.type('css=input.input-medium.email',user)
.type('css=input.input.pwd',pass)
.clickAndWait('css=a.btn.login')
.assertTextPresent('Clients',function(){ console.log('logged in ok')})
}
}
function verifyData() {
var startRowId=27
console.log('inside TestingSpreaddsheet')
var totalLoop=(rowcount-5)+1
return function(browser) {
browser
for (var i = 1; i <= 4; i++) {
browser.assertText('css=div.keyYears table tbody tr:nth-child('+i+') td:nth-child(3)',''+ cellsData[startRowId].numValue +'',function(){ console.log('looks good')})
.assertText('css=div.keyYears table tbody tr:nth-child('+i+') td:nth-child(5)',''+ cellsData[startRowId].numValue +'')
.assertText('css=div.keyYears table tbody tr:nth-child('+i+') td:nth-child(6)',''+ cellsData[startRowId].numValue +'')
.assertText('css=div.keyYears table tbody tr:nth-child('+i+') td:nth-child(7)',''+ cellsData[startRowId].numValue +'')
}
}
}
更新 Soda 在获取我的 ExcelSheet 数据之前运行链。如何控制链条?