Using custom JavaScript in Nightwatch, I am retrieving various values from a web page.
browser.execute(function () {
priceValues = {
total: document.querySelectorAll('someLocator').innerText,
individualPrice: document.querySelectorAll('someLocator').innerText,
discount: document.querySelectorAll('someLocator').innerText,
};
return priceValues;
}, [], function (result) {
totalPrice = result.value.total;
individual = result.value.individualPrice;
discountPrice = result.value.discount;
});
An issue I'm encountering is that in some tests, the discount value is not available, resulting in undefined. However, this is causing the other two values, total and individualprice, which do have values, to also become undefined. Can anyone help me identify what I might be doing wrong here?