-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Protractor-Cucumber.js throwing undefined snippet error while running feature file #1070
Comments
In the future, please post on the protractor-cucumber-framework repo first and only post here once determined it is a cucumber issue. Also please use syntax highlighting with code blocks (I added some to the original post) and ensure your pasted code is formatted nicely so it is easy to read. For the first steps.js, the regexp for I'm not sure whats going on with the second steps.js. |
I will make sure of your suggestions. Given(/^I launch "(.*)"$/, function (myvar) { Then(/^I enter "(.*)"$/, function(textabc) { and updated glob in protractor config.js file as per your suggestions but I am still getting below issue:
(node:1860) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
2/2 steps [=================================================================================================================================] 1 scenario (1 undefined) |
Those steps won't match as the step definition has quotes around the url and search query while the text in the feature file does not have text |
ok!! Then(/^I enter .*$/, function(textabc) { and Given(/^I launch (.*)$/, function (myvar) { Then(/^I enter (.*)$/, function(textabc) { with these implementation I am getting below:
(node:12464) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead. My concern is, in which scenario cucumber directly skip steps. |
Just noticed that you have |
ok!! I have made it to false.
(node:6512) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
2/2 steps [=================================================================================================================================] 1 scenario (1 failed) |
What is your step definition now? I expect you aren't capturing the url with the regexp when you want to be. // This won't work as your regexp isn't capturing anything
// and thus the function will not receive the url as an argument
// It is receiving a callback instead as based on the number of parameters the
// function accepts it assumes you are using the callback interface
Given(/^I launch .*$/, function (myvar) {
browser.get(myvar);
});
// This should work
Given(/^I launch (.*)$/, function (myvar) {
browser.get(myvar);
}); |
I was capturing url through regexp (.*), I have now modified my files as below: Step.js
when I executed feature file It is working fine
(node:9748) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead. Thank you so much for solving my issues. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
PFB Details:
"cucumber": "^4.2.1",
"protractor": "^5.3.1",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"protractor-cucumber-framework": "^4.2.0",
Node 9.10.0
NPM 5.6.0
config.js file:
// conf.js
exports.config = {
framework: 'custom',
seleniumAddress: 'http://localhost:4444/wd/hub',
frameworkPath: require.resolve('protractor-cucumber-framework'),
ignoreUncaughtExceptions: true,
specs: [
'test/features/*.feature' // accepts a glob
],
cucumberOpts: {
timeout: '10000',
// require step definitions
require: [
'test/features/step_definitions/.*steps.js' // accepts a glob
],
tags:['@test5'],
strict: true, // fail if there are any undefined or pending steps
'dry-run': true, // invoke formatters without executing steps
compiler: []
},
// rootElement: 'div#nested_ngcontent',
useAllAngular2AppRoots: true,
capabilities: {
'browserName': 'chrome'
},
chromeOnly: true,
}
FeatureFile:
@test5
Feature: Login to WebApp
Scenario Outline: Login
Given I launch
Then I enter
Examples:
| myvar | textabc |
| https://www.google.com | google |
Page.js(where method is implimented):
'use strict'
const googleP = require('../../test/screens/googleScreen');
class googlename {
constructor() {
}
module.exports = googlename;
Screen.js(where locators are defined):
'use strict'
// import { element, By } from "protractor";
class google {
constructor() {
this.txt_search = element(by.id('q'));
}
}
module.exports = google
step.js:
'use strict'
const { Before, Given, Then } = require('cucumber');
var {defineSupportCode} = require('cucumber');
var {setDefaultTimeout} = require('cucumber');
const chai = require('chai');
const {expect} = require('chai');
const assert = require('assert');
const googlePage = require('../../pages/googlePage');
browser.ignoreSynchronization=true;
Before({timeout: 60 * 1000}, function() {
setDefaultTimeout(60 * 1000);
});
Given(/^I launch .* $/, function(myvar) {
return browser.get(myvar);
});
Then(/^I enter (.*)$/, function(textabc) {
const google = new googlePage();
return google.entertext(textabc);
});
while executing feature file with above step definition I am getting below error:
(node:2332) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[13:14:42] I/launcher - Running 1 instances of WebDriver
[13:14:42] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
Scenario: Login # test\features\google.feature:8
Before # test\features\step_definitions\googlesteps.js:12
? Given I launch https://www.google.com
Undefined. Implement with the following snippet:
? Then I enter google
Undefined. Implement with the following snippet:
2/2 steps [=================================================================================================================================] 1 scenario (1 undefined)
2 steps (2 undefined)
0m00.000s
[13:14:46] I/launcher - 0 instance(s) of WebDriver still running
[13:14:46] I/launcher - chrome #1 failed 1 test(s)
[13:14:46] I/launcher - overall: 1 failed spec(s)
[13:14:46] E/launcher - Process exited with error code 1
npm ERR! Test failed. See above for more details.
b) step.js
'use strict'
const { Before, Given, Then } = require('cucumber');
var {defineSupportCode} = require('cucumber');
var {setDefaultTimeout} = require('cucumber');
const chai = require('chai');
const {expect} = require('chai');
const assert = require('assert');
const googlePage = require('../../pages/googlePage');
browser.ignoreSynchronization=true;
Before({timeout: 60 * 1000}, function() {
setDefaultTimeout(60 * 1000);
});
Given('I launch {string}', function(myvar) {
browser.get(myvar);
return true;
});
Then('I enter {string}', function(textabc) {
const google = new googlePage();
return google.entertext(textabc);
});
while running above step.js I am facing below error:
(node:14528) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[12:53:01] I/launcher - Running 1 instances of WebDriver
[12:53:01] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
1 scenario (1 skipped)
2 steps (2 skipped)
0m00.000s
[12:53:04] I/launcher - 0 instance(s) of WebDriver still running
[12:53:04] I/launcher - chrome #1 passed
Please help me to understand what exactly is going wrong in my code and help me to solve it
The text was updated successfully, but these errors were encountered: