I am looking to get a row count of items returned so I can later add a filter to the list. Then I will assert that the filtered list number is less than the total number.
I have tried a number of .perform and .execute arrangements and continue to get undefined errors.
module.exports = {
'Verify rows': function (browser) {
var value_id = 0;
browser
.url(browser.launchUrl)
.waitForElementVisible('body', 20000)
.pause(4000)
.verify.visible('div:nth-of-type(2) > form > div > div > div > div')
.assert.gdGreater('.offering-item-container', 0)
.execute(function () {
value_id = document.querySelectorAll('.offering-item-container').length;
})
.click('#IsGuaranteedToRun')
.pause(4000)
.assert.gdLess('#IsGuaranteedToRun', value_id)
}
};
I found an answer here that helped point me in the right direction. Then I had to include the next steps within the callback.
module.exports = {
'Verify rows': function (browser) {
var value_id = 0;
browser
.url(browser.launchUrl)
.waitForElementVisible('body', 20000)
.pause(4000);
const numElementsPromise = new Promise(resolve => {
browser.elements('css selector', '.offering-item-container', result => {
resolve(result.value.length);
});
});
numElementsPromise.then(result => {
value_id = result;
browser
.pause(4000)
.verify.visible('div:nth-of-type(2) > form > div > div > div > div')
.assert.gdGreater('.offering-item-container', 0)
.click('#IsGuaranteedToRun')
.pause(4000)
.assert.gdLess('.offering-item-container', value_id)
.click('#IsGuaranteedToRun')
.assert.gdEquals('.offering-item-container', value_id);
});
}
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.