0
我有一个表格列,格式为2014年1月1日的不同人的出生日期。我需要检查此列中显示的所有出生日期是否在特定范围内在2012年1月1日至2016年1月1日之间。 我可能会将我的日期范围作为变量传递给我,并比较从量角器脚本中的表格列获得的值。下面是一段代码我已经写验证日期在特定格式的给定范围内
this.matchRange = function(value){
this.names = element.all(by.repeater('row in jsonResponse').column(value));
var startDate = 'Jan 1, 2012';
var endDate = 'Jan 1, 2016';
this.inResults = function(nameString){
return this.names.filter(function(name){
return name.getText().then(function(testDate){
console.log(testDate);
//expect(text).toMatch(nameString)
return testDate >= startDate &&
testDate <= endDate;
});
}).then(function(filteredElements){
// Only the elements that passed the filter will be here. This is an array.
return filteredElements.length > 0;
});
};
};
为什么不简单地将你的开始日期,结束日期转换成长格式,并将所有上下文日期类似地转换为长格式,并检查它们是否位于开始日期,结束日期 –
@ Vinod Louis感谢您的快速响应,我是JavaScript新手,所以不知道如何编写你的建议,你能帮我吗? –