this is not nightwatch api in step definition functions.
See original GitHub issueI’m submitting a … (check one with “x”)
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead use https://groups.google.com/d/forum/nightwatch-cucumber
Current behavior
"cucumber": "^1.3.1",
"nightwatch": "^0.9.6",
"nightwatch-cucumber": "^5.5.2",
// client/tests/e2e/steps/index.js
var debug = require('debug')('test/e2e/steps');
module.exports = function () {
debug('loading');
require('../parts/general').call(this, options);
debug('ready');
};
// client/tests/e2e/parts/general.js
/*eslint no-param-reassign: "options" */
var debug = require('debug')('test/e2e/parts/general');
module.exports = function (options) {
debug('loading');
options = Object.assign({}, options);
/**
* Assert something displays the text
* @param {any} selector xPath selector
* @param {String} text text to confirm
*/
this.Then('"$selector" should display "$text"',
function assertTextIsDisplayed (selector, text, done) {
debug('Then.assertTextIsDisplayed', selector);
this.useXpath()
getText(selector, function (result) {
this.assert.equal(typeof result, 'object');
this.assert.equal(result.status, 0);
this.assert.equal(result.value, text);
done();
});
});
}
...
Step Definition: client/test/e2e/parts/general.js:16
Message:
TypeError: this.useXpath is not a function
...
Expected/desired behavior
That this inside a step definition be the nightwatch api.
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Developer Guide - Nightwatch.js
In depth guides on how to use Nightwatch to write and execute tests.
Read more >client.elements is not working from a step definition using ...
I'm trying to do nightwatch and cucumber integration for BDD. I'm unable to access client.elements function in a step function. const { client...
Read more >Using with Cucumber - Nightwatch API
For Cucumber to be able to understand and execute the feature file we need to create matching step definitions for every feature step...
Read more >Crazy Powerful Nightwatch.js Cucumber Step Definitions
There are two problems with the smart step definition approach. First of all the backticks, which are used to mark selectors, destroy the...
Read more >Need help regarding terminating session for each scenario ...
I have developed a framework using nightwatch along with cucumber. ... Now i have problem lets say last step definition of a test...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I beg to differ.
Without the callback, subsequent steps begin to execute before the current step has finished, this causing failure of my tests.
Essentially I 'm not sure I see the point of a step definition that can’t make use of the nightwatch api?
At the moment I’m on a tight deadline where every minute I spend costs the client money. I’ve already spent far too much time trying to workout why my tests were failing…
Some of my step definitions absolutely require some kind of asynchronous behaviour, that should be either one of : a generator, a Promise or a callback.
For now I had to roll back to an older version of your library. where I won’t have beforeEach or afterEach support.
You can return promise in step definition. And it will async
Or you can you generators
Hope this helps. I will close the separately ceated issue #146