I have a function that i am trying to call from another function within the pageobjects file.
this.clickbutton = function(method){
if(method == 'phone'){
phonebutton.click();
comment.sendKeys('comments');
submitbutton.click();
}else if(method == 'email'){
emailbutton.click();
}else if(method == 'sms'){
smsbutton.click();
}else{
rowphonebutton.click();
comment.sendKeys('comments');
submitbutton.click();
}
};
My another function within the same PO file.
this.contactagentAll = function(method){
getrow.count().then(function(cnt){
if(cnt>0){
this.clickbutton(method);
getrow.count().then(function(cnt1){
expect(cnt1).toEqual(0);
});
}else{
console.log('no records found');
}
});
};
I get the error saying - Failed: this.clickbutton is not a function. any suggestions pls?