I'm new to protractor using javascript, I created a simple script that calls data from another js file.
I have a file called jsobjectdemo.js that contains
<pre>
this.productnames = element.all(by.tagName("app-card"));
this.cartblock = element(by.css("h4 a"));
this.addcartbutton = element(by.css("button[class='btn btn-info']"));
</pre>
And another file called jscalldemo.js
var cart = require('./jsobjectdemo.js');
function addCart(productname){
cart.productnames.each(function(item){
cart.cartblock.getText().then(function(text){
if (text==productname){
cart.addcartbutton.click();
}
})
})
}
When i ran the script, it returns an error
Message: Failed: Cannot read property 'cartblock' of undefined Stack: TypeError: Cannot read property 'cartblock' of undefined at D:\Trainings\Protractor\protractor-workspace\Protractor\jscalldemo.js:8:14