Reputation: 1
I am learning Intern/leadfoot and trying to write a simple test. The test is logging an user to the site and logging out the user after verification on the next page.
Using Chromedriver v2.21.
Getting unknown error : Expecting a function in instanceof check, but got [object Object] for click() method for an element. However, the element is being identified and get the value for getVisibleText().
Here is my test Code:
define(function (require) {
var registerSuite = require('intern!object');
var assert = require('intern/chai!assert');
registerSuite({
name: 'Acceptance',
'Login': function () {
return this.remote
.get(require.toUrl('http://example.com'))
.setFindTimeout(5000)
.findByXpath('id("ius-userid")')
.click()
.type('[email protected]')
.end()
.findByXpath('id("ius-password")')
.click()
.type('password')
.end()
.findByXpath('id("ius-sign-in-submit-btn")')
.click()
.end()
.sleep(15000)
},
'HomePage': function () {
return this.remote
.setFindTimeout(5000)
.findByXpath('id("userWelcome")')
.getVisibleText()
.then(function (text) {
assert.strictEqual(text, 'Welcome [email protected]!', 'Vaerify that, the Home page for the logged in user is displayed!');
})
.end()
.findByXpath('id("settingsAndLogout")/A[2]')
.getVisibleText()
.then(function(text){
console.log("The Sign out link text is :...", text.trim());
assert.strictEqual(text.trim(), 'Sign Out', 'Verify that, the Sign Out link is present.');
})
.click()
.end()
}
});
});
And, here is the output:
Listening on 0.0.0.0:9000
Tunnel started
? Created session chrome on any platform (5fcd3559690a324e3a5a3db6cd367387)
√ chrome on any platform - Acceptance - Login (20.268s)
The Sign out link text is :... Sign Out
x chrome on any platform - Acceptance - HomePage (0.13s)
UnknownError: [POST http://localhost:4444/wd/hub/session/5fcd3559690a324e3a5a3db
6cd367387/element/0.8815118646376954-2/click] unknown error: Expecting a functio
n in instanceof check, but got [object Object]
(Session info: chrome=49.0.2623.112)
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7
c4),platform=Windows NT 6.1 SP1 x86_64)
at runRequest <node_modules\leadfoot\Session.js:88:40>
at <node_modules\leadfoot\Session.js:109:39>
at new Promise <node_modules\dojo\Promise.ts:411:3>
at ProxiedSession._post <node_modules\leadfoot\Session.js:63:10>
at Element._post <node_modules\leadfoot\Element.js:23:31>
at Element.click <node_modules\leadfoot\Element.js:138:15>
at Command.<anonymous> <node_modules\leadfoot\Command.js:680:19>
at <node_modules\dojo\Promise.ts:393:15>
at run <node_modules\dojo\Promise.ts:237:7>
at <node_modules\dojo\nextTick.ts:44:3>
at Command.target.(anonymous function) [as click] <node_modules\leadfoot\Comm
and.js:674:11>
at Test.registerSuite.IQC_HomePage [as test] <tests\functional\IQC_Acceptance
.js:44:7>
at <node_modules\intern\lib\Test.js:181:24>
at <node_modules\intern\browser_modules\dojo\Promise.ts:393:15>
at runCallbacks <node_modules\intern\browser_modules\dojo\Promise.ts:11:11>
at <node_modules\intern\browser_modules\dojo\Promise.ts:317:4>
at run <node_modules\intern\browser_modules\dojo\Promise.ts:237:7>
at <node_modules\intern\browser_modules\dojo\nextTick.ts:44:3>
at nextTickCallbackWith0Args <node.js:453:9>
at process._tickCallback <node.js:382:13>
No unit test coverage for chrome on any platform
Need help in figuring out the issue. Thanks in advance!
Upvotes: 0
Views: 178
Reputation: 1
Here's a suggestion:
.findByXpath('id("settingsAndLogout")/A[2]')
.getVisibleText()
.then(function(text){
console.log("The Sign out link text is :...", text.trim());
assert.strictEqual(text.trim(), 'Sign Out', 'Verify that, the Sign Out link is present.');
})
.end()
.findByXpath('id("settingsAndLogout")/A[2]')
.click()
.end()
Not the most elegant solution as findbyXpath is redundant. But the thing is, .click() expects that previous command/element promise returns actual element when resolved (findByXpath will do that).
Hope this helps!
Upvotes: 0