【发布时间】:2021-06-24 17:53:15
【问题描述】:
我正在使用 NightWatch JS,我有一个问题,我如何比较字符串并检查 NightwatchJS 循环中的唯一性?
My code module.exports = {
test: function(client) {
var text1;
client
.maximizeWindow()
.url('https://gitlab.com/')
.waitForElementVisible('svg.nav-logo', 10 * 1000)
.click('#CybotCookiebotDialogBodyLevelButtonAccept')
.useXpath()
.moveToElement('(//h2[contains(text(),"The latest from our blog")]//following-sibling::div/a/div/h4)',1,1)
.waitForElementVisible('(//h2[contains(text(),"The latest from our blog")]//following-sibling::div/a/div/h4)', 10 * 1000)
.elements('xpath','(//h2[contains(text(),"The latest from our blog")]//following-sibling::div/a/div/h4)',
function(elements)
{
elements.value.forEach(function(elementsObj)
{
client.elementIdText(elementsObj.ELEMENT,function(result){
text1 = result.value;
console.log(text1);
})
})
})
.pause(10*1000);
}
};
在控制台中,我收到了预期的结果(3 个字符串) 有一个问题,我现在如何检查,如何比较每个字符串在循环中是唯一的?
【问题讨论】:
标签: javascript xpath automation nightwatch.js