我可以用下面的代码块来完成:
browser.execute(function () {
priceValues = {
total: document.querySelectorAll('someLocator').innerText,
individualPrice: document.querySelectorAll('someLocator').innerText,
};
var discount = document.querySelectorAll('someLocator'),
if (discount && discount.innerText) {
priceValues.discount = discount.innerText;
}
return priceValues;
}, [], function (result) {
totalPrice = result.value.total;
individual = result.value.individualPrice;
discountPrice = result.value.discount;
});