I am seeing following issue when I am using Expected Conditions on webelements returned through element object of Protractor. I tried with $ as well, that resulted in the same thing. I am using Protractor 3.1.1 on Node 4.2.4, Chrome V47.*
"Type Error: Cannot read property 'bind' of undefined"
Before asking, I searched the forums, and understood there are some known issues with using Expected Conditions with selenium elements using driver.findElement.
However, I could not come across a similar issues reported while using element object itself.
https://github.com/angular/protractor/issues/1853
We have a non angular app for login page, which will be switched to Angular, post login. So, I have set ignoreSynchronization=true and later planned to reset it to false after login. Below is the sample code, appreciate any thoughts from community.
Page Objects File
module.exports = {
login: element(by.model('credentials.username')),
password: element(by.model('credentials.password')),
user: "Email",
passwd: "Password",
goButton: $('input.btn.btn-primary'),
EC: protractor.ExpectedConditions,
go: function() {
browser.get("Application URL",30000);
browser.wait(this.EC.elementToBeClickable(this.login),30000);
},
Below is my Sample Test Suite
var VMPage = require('./LoginPage.js');
describe('App Demo', function() {
beforeEach(function() {
console.log("Before Each Started");
browser.driver.manage().timeouts().implicitlyWait(30000);
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1800000;
browser.ignoreSynchronization = true;
VMPage.go();
VMPage.login();
});
it('Test Case', function() {
console.log("***Test Started***");
});
});
Stack trace reported looks as follows: Stack:
TypeError: Cannot read property 'bind' of undefined
at [object Object].ExpectedConditions.presenceOf (C:\Users\PJ\Ap
pData\Roaming\npm\node_modules\protractor\lib\expectedConditions.js:289:33)
at [object Object].ExpectedConditions.visibilityOf (C:\Users\PJ\
AppData\Roaming\npm\node_modules\protractor\lib\expectedConditions.js:328:10)
at [object Object].ExpectedConditions.elementToBeClickable (C:\Users\PJ0
0366401\AppData\Roaming\npm\node_modules\protractor\lib\expectedConditions.js:17
8:12)
at Object.module.exports.go (D:\protractor_git\Demo\\Log
inPage.js:14:24)
at Object.<anonymous> (D:\protractor_git\Demo\\LoginTest
.js:9:10)
at C:\Users\PJ\AppData\Roaming\npm\node_modules\protractor\node_
modules\jasminewd2\index.js:96:23
at new wrappedCtr (C:\Users\PJ\AppData\Roaming\npm\node_modules\
protractor\node_modules\selenium-webdriver\lib\goog\base.js:2468:26)
at controlFlowExecute (C:\Users\PJ\AppData\Roaming\npm\node_modu
les\protractor\node_modules\jasminewd2\index.js:82:18)
From: Task: Run beforeEach in control flow
at Object.<anonymous> (C:\Users\PJ\AppData\Roaming\npm\node_modu
les\protractor\node_modules\jasminewd2\index.js:81:14)
at attemptAsync (C:\Users\PJ\AppData\Roaming\npm\node_modules\pr
otractor\node_modules\jasmine\node_modules\jasmine-core\lib\jasmine-core\jasmine
.js:1916:24)
at QueueRunner.run (C:\Users\PJ\AppData\Roaming\npm\node_modules
\protractor\node_modules\jasmine\node_modules\jasmine-core\lib\jasmine-core\jasm
ine.js:1871:9)
at QueueRunner.execute (C:\Users\PJ\AppData\Roaming\npm\node_mod
ules\protractor\node_modules\jasmine\node_modules\jasmine-core\lib\jasmine-core\
jasmine.js:1859:10)
at Spec.Env.queueRunnerFactory (C:\Users\PJ\AppData\Roaming\npm\
node_modules\protractor\node_modules\jasmine\node_modules\jasmine-core\lib\jasmi
ne-core\jasmine.js:697:35)
at Spec.execute (C:\Users\PJ\AppData\Roaming\npm\node_modules\pr
otractor\node_modules\jasmine\node_modules\jasmine-core\lib\jasmine-core\jasmine
.js:359:10)
at Object.fn (C:\Users\PJ\AppData\Roaming\npm\node_modules\protr
actor\node_modules\jasmine\node_modules\jasmine-core\lib\jasmine-core\jasmine.js
:2479:37)
at attemptAsync (C:\Users\PJ\AppData\Roaming\npm\node_modules\pr
otractor\node_modules\jasmine\node_modules\jasmine-core\lib\jasmine-core\jasmine
.js:1916:24)
at QueueRunner.run (C:\Users\PJ\AppData\Roaming\npm\node_modules
\protractor\node_modules\jasmine\node_modules\jasmine-core\lib\jasmine-core\jasm
ine.js:1871:9)
at QueueRunner.execute (C:\Users\PJ\AppData\Roaming\npm\node_mod
ules\protractor\node_modules\jasmine\node_modules\jasmine-core\lib\jasmine-core\
jasmine.js:1859:10)
From asynchronous test:
Error
at Suite.<anonymous> (D:\protractor_git\Demo\\LoginTest.
js:3:2)
at addSpecsToSuite (C:\Users\PJ\AppData\Roaming\npm\node_modules
\protractor\node_modules\jasmine\node_modules\jasmine-core\lib\jasmine-core\jasm
ine.js:833:25)
at Env.describe (C:\Users\PJ\AppData\Roaming\npm\node_modules\pr
otractor\node_modules\jasmine\node_modules\jasmine-core\lib\jasmine-core\jasmine
.js:802:7)
at jasmineInterface.describe (C:\Users\PJ\AppData\Roaming\npm\no
de_modules\protractor\node_modules\jasmine\node_modules\jasmine-core\lib\jasmine
-core\jasmine.js:3375:18)
at Object.<anonymous> (D:\protractor_git\Demo\\LoginTest
.js:2:1)