У меня есть пользовательская команда: initialCount.js
module.exports = {
command: function () {
this
.getText('.header-mini-cart-menu-cart-legend', function (result) {
cartCountInitial = Number(result.value); <--- I want this output into some other command.
console.log(cartCountInitial); <---- Prints the count in number.
return cartCountInitial; <--- I want this output into some other command
});
}
Я хочу использовать значение в условии IF, которое находится в другом файле (в тестовом примере).
контрольный примеримя файла: addToCartFromTile.test.js
var initialCartCount = require('../../../commands/shopping/cart/initialCartCount');
module.exports= {
'Determining whether the product is MATRIX or NON-MATRIX': client => {
client
.url(client.launchUrl)
.getLocationInView(noOfSliders)
.execute(function () {
var cartCount = document.querySelector('.header-mini-cart-menu-cart-legend').innerText;
return cartCount;
},[],function(res){
var cartCount1 = Number(res.value);
if (initialCartCount.command == cartCount1) { <---- "initialCartCount.command" returns me {command: [Function: command]}.
}
«initialCartCount.command» в условии IF, возвращает меня {команда: [Функция: команда]} ,Как получить значение переменной.
Есть ли взлом или подход неправильный.Если мой подход неверен, то, пожалуйста, предложите, как мне этого добиться?