Closed Eriusik closed 4 years ago
Possible a duplicate of https://github.com/nightwatchjs/nightwatch/issues/2285.
This issue has been automatically marked as stale because it has not had any recent activity. If possible, please retry using the latest Nightwatch version and update the issue with any relevant details. If no further activity occurs, it will be closed. Thank you for your contribution.
Describe the bug
It doesn't work after upgrade from 1.24 to 1.3.2. TypeError: Error while running "elements" command: Function.prototype.apply was called on a.btn-download, which is a string and not a function
Page Object
TestPage.js
```js module.exports = { sections: { buttons: { selector: '#index-container .download .download', elements: { downloadButton: 'a.btn-download' }, commands: [{ checkInstall: function() { this.api.elements('css selector', this.elements.downloadButton.selector, function(result) { console.log(result); }); return this; } }] } }, } ```
Test
sampleTest.js
```js const test = { tags: ['1browser'], '@disabled': false, before: function (browser) { }, 'Test open nightwatch': function(browser) { const testSection = browser.page.TestPage().section.buttons; browser.url('https://nightwatchjs.org/'); testSection.checkInstall(); }, after: function (browser) { browser.end(); } }; module.exports = test; ```
Run with command
Verbose output
debug.log
```txt → Completed command: url ('https://nightwatchjs.org/') (2206ms) → Running command: elements ({name, __index, __selector, locateStrategy, pseudoSelector, parent, resolvedElement}, 'a.btn-download', [Function]) Request POST /wd/hub/session/cff0f32f33f39bf480355b2f1d81f296/elements { using: 'css selector', value: '#index-container .download .download' } Response 200 POST /wd/hub/session/cff0f32f33f39bf480355b2f1d81f296/elements (20ms) { sessionId: 'cff0f32f33f39bf480355b2f1d81f296', status: 0, value: [ { ELEMENT: '0.689523917421961-1' } ] } Request POST /wd/hub/session/cff0f32f33f39bf480355b2f1d81f296/element/0.689523917421961-1/elements { using: 'css selector', value: 'css selector' } Response 200 POST /wd/hub/session/cff0f32f33f39bf480355b2f1d81f296/element/0.689523917421961-1/elements (15ms) { sessionId: 'cff0f32f33f39bf480355b2f1d81f296', status: 0, value: [] } → Completed command: elements ({name, __index, __selector, locateStrategy, pseudoSelector, parent, resolvedElement}, 'a.btn-download', [Function]) (39ms) → Running [afterEach]: → Completed [afterEach]. FAILED: 1 errors (2.371s) TypeError: Error while running "elements" command: Function.prototype.apply was called on a.btn-download, which is a string and not a function at processTicksAndRejections (internal/process/task_queues.js:93:5) → Running [after]: → Running command: end () ```
Configuration
nightwatch.json
```js { "your": { "config": "here" } } ```
Your Environment
nightwatch --version
npm --version
yarn --version
node --version