我正在编写量角器测试并喜欢它,虽然有时似乎陷入了似乎应该简单的事情.例如,我想循环浏览其中一个页面上具有"Nominate"文本的所有按钮.页面上有几十个,但只有1或2个可见.所以我想点击第一个.这是我目前使用的代码:
var nominateButtons = element.all(by.buttonText('Nominate'));
nominateButtons.then(function(els){
for(var x = 0;x < els.length;x++){
//Since isDisplayed returns a promise, I need to do it this way to get to the actual value
els[x].isDisplayed().then(function(isVisible){
//isVisible now has the right value
if(isVisible){
//But now els is not defined because of the scope of the promise!!
els[x].click();
}
});
}
});
Run Code Online (Sandbox Code Playgroud)
当我运行此代码时,我得到一个'无法调用方法点击未定义'错误,因为els [x]不再在范围内,但我似乎无法在不使用promise的情况下检查可见性.所以我的问题是,你怎么能循环遍历一系列元素,检查它们的可见性,然后点击第一个可见元素?(我试图不使用期望来检查可见性,因为我知道大多数按钮都不可见)
提前致谢
我是NetSuite的新手,所以我确定这是愚蠢的我做错了,但我正在尝试在脚本中查找帐户的最新支票号码.所以我在CustomerPayment表上为checkNum列设置搜索.我是这样做的:
var acct = nlapiGetFieldValue('account');
var paymentFilters = new Array();
paymentFilters[0] = new nlobjSearchFilter('account', null, 'anyof', acct);
var paymentColumns = new Array();
paymentColumns[0] = new nlobjSearchColumn('checknum');
var paymentSearchResults = nlapiSearchRecord('customerpayment', null, paymentFilters, paymentColumns);
Run Code Online (Sandbox Code Playgroud)
但我得到一个"一个nlobjSearchColumn包含一个无效的列,或者没有正确的语法:checknum"错误.我验证了有一个CustomerPayment表,并且其中还有一个checkNum列.至少记录浏览器似乎暗示了这一点.(也是我第一次使用它)我还验证了acct包含我期望它的值.
我做了几个其他搜索,使用基本相同的代码,它们似乎按预期工作,所以我不确定我做错了什么.例如,此代码似乎有效:
var filters = new Array();
filters[0] = new nlobjSearchFilter('account', null, 'anyof', acct);
var columns = new Array();
columns[0] = new nlobjSearchColumn('tranid');
var searchResults = nlapiSearchRecord('check', null, filters, columns);
Run Code Online (Sandbox Code Playgroud)
无论如何,任何帮助将不胜感激.谢谢.