Getting a Failed: Cannot read property 'bind' of undefined
Page Object class:
this.popupToastIP = function(){
element.all(by.className('toast-success toast ng-trigger ng-trigger-
flyInOut')).then(function(){
element(by.className('toast-success toast ng-trigger ng-trigger-flyInOut')).getText();
});
Test spec:
browser.wait(EC.visibilityOf(publisher_whitelist_page.popupToastIP),5000);
expect(publisher_whitelist_page.popupToastIP.toEqual('Ip address removed'));
Have tried removing the 'all' but to no avail - still with same error (followed advice of post undefined property 'bind' when using expected conditions
Any help would be greatly appreciated!
Thanks!
Kirsty
EDIT
Tried adding bind but again to no avail.
this.popupToastIP = function(){
element.all(by.className('toast-success toast ng-trigger ng-trigger-
flyInOut')).then(function(){
element(by.className('toast-success toast ng-trigger ng-trigger-
flyInOut')).getText();
}).bind(this);
};
You code is wrong, it dose no matter with protractor or other stuff. Another thing could you indent your code for others easy to read.
1) What the final pupose of this function, to get text from an element or to
find an element?
this.popupToastIP = function(){
element.all(by.className('toast-success toast ng-trigger ng-trigger-flyInOut'))
.then(function(){
element(by.className('toast-success toast ng-trigger ng-trigger-flyInOut'))
.getText();
});
}
Issue 1
why you find element by same class name twice, the element.all(xxx) is redundant, because you no use its result in the following then().
Issue 2
you not return value for function, but your code in Test Spec require it has return value.
2) Your code in Test Spec as below, require popupToastIP return an element and the text of element, they are conflict already.
browser.wait(EC.visibilityOf(publisher_whitelist_page.popupToastIP),5000); // require return an element
expect(publisher_whitelist_page.popupToastIP.toEqual('Ip address removed')); // require return text of element
Issue 1
you decleared the popupToastIP as a function, you missed () behind it. It's no possbile for a function will be visible on page and equal to 'Ip address removed'
try below code
// Page Object
this.popupToastIP = element(by.className('toast-success toast ng-trigger ng-trigger-flyInOut'));
// Test Spec
browser.wait(EC.visibilityOf(publisher_whitelist_page.popupToastIP),5000);
expect(publisher_whitelist_page.popupToastIP.getText()).toEqual('Ip address removed'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With