我正在对nightwatch.js进行测试,目的是比较2个数组值; transmissionSolrQueryResult 是Solr查询的结果, transmissionFacetEntryPageResult 是构面文本值的结果。
所以,这是我现在的代码;
"Page 1 Transission SEO Crawl paths are correct": function (browser) {
// Transmission Solr Query Result Array
var transmissionArray = ryanlinkstransmissionpage.Transmission.filter(val => typeof val === "string");
transmissionArray.sort().forEach(function(transmissionSolrQueryResult) {
console.log(transmissionSolrQueryResult);
});
// Transmission Facet Navigation
browser.elements('xpath', '//a[contains(@href,"gearbox")]', function (transmissionFacetEntry) {
transmissionFacetEntry.value.map(function(element) {
browser.elementIdAttribute(element.ELEMENT, 'innerText', function(transmissionFacetEntryResult) {
var transmissionFacetEntryPageResult = transmissionFacetEntryResult.value;
console.log(transmissionFacetEntryPageResult);
// Array comparison code
function arraycompare(transmissionSolrQueryResult, transmissionFacetEntryPageResult) {
var finalArray =[];
transmissionSolrQueryResult.forEach((array1) => transmissionFacetEntryPageResult.forEach((array2) =>
{ if(array1 === array2){
var finalArrayComparision = finalArray.push(array1);
console.log(finalArrayComparision);
}
}
));
}
});
});
});
},
应在 transmissionSolrQueryResult 和 transmissionFacetEntryPageResult 这两个数组之间进行比较,并输出到终端;
console.log(finalArrayComparision)
但是,似乎没有运行阵列比较代码块。
以下内容输出到终端;
Starting selenium server... started - PID: 9978
[PAR 4605 Audi] Test Suite
==============================
✔ Make level page 1 loads (6.086s)
✔ Agree to cookie policy (1.095s)
Automatic
Manual
Automatic
Manual
✔ Page 1 Transission SEO Crawl paths are correct (49ms)
✔ Closing the browser (56ms)
OK. 2 total assertions passed. (7.675s)
但没有别的。
我明显做错了吗?
我认为我的代码是正确的,但是可能不是正确的“顺序”,还是应该归咎于错误的括号?
任何帮助将不胜感激。
谢谢。