0

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?

Mallesh JM
  • 23
  • 1
  • 6
  • 1
    This is a common question: http://stackoverflow.com/q/20279484/398606 – Sunil D. Sep 05 '16 at 15:34
  • how can this be duplicate. the existing one question pointed to is not at all related to protractor. – Mallesh JM Sep 05 '16 at 15:58
  • It's a duplicate b/c the problem actually has nothing to do with Protractor, and is just a common problem that people encounter with javascript. If you're stuck, use the `var self = this;` trick in the answer to the linked question. – Sunil D. Sep 05 '16 at 18:38
  • @SunilD. thank you :) – Mallesh JM Sep 06 '16 at 08:45

0 Answers0