-
Notifications
You must be signed in to change notification settings - Fork 118
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
Facing issue with defining steps when additional functions involved. #18
Comments
@bencompton can you please let us know your comments on the issue. Thanks in Advance. |
Hi @darkhorse93, I haven't used Selenium from Node in several months and am not immediately familiar with |
Thanks @bencompton for your comment, I've tried setting up a simple project, Selenium WebDriver with Jest-Cucumber, it went fine with no issues. Facing issue when I try to change the (above mentioned)existing script in our project to work with Jest-Cucmber, i.e.
Is there anyway that I can call the It would be great if you can give any other suggestions/workarounds... |
@darkhorse93, thanks for clarifying. So the issue seems to be that your Have you tried something like this? const appUrl = process.env.HOMEPAGE URL
let appDriver = null;
defineFeature(RndHpyPath,test=>{
beforeEach(async () => {
await withWebDriver(async function(webDriver) {
appDriver=new TGDriver({webDriver, appUrl});
});
});
test('Happy Path Scenario Test',({given,when,then})=>{
given('Happy Path Scenario Precondition', async () {…})
when('Happy Path Scenario Action and Condition', async(){…})
then('Happy Path Scenario Action and Condition Validations', async() {…})
});
}); This assumes that your |
Thanks for the suggesstion @bencompton , but in the suggested |
So something like this maybe? const appUrl = process.env.HOMEPAGE URL
let appDriver = null;
defineFeature(RndHpyPath, test => {
const initWebDriver = () => {
await withWebDriver(async (webDriver) => {
appDriver = new TGDriver({webDriver, appUrl});
});
}
test('Happy Path Scenario Test',({ given, when, then })=>{
given('Happy Path Scenario Precondition', async () => {
await initWebDriver();
//Your test code goes here (appDriver will be populated now)
});
when('Happy Path Scenario Action and Condition', async () => {
await initWebDriver();
//Your test code goes here (appDriver will be populated now)
});
then('Happy Path Scenario Action and Condition Validations', async() {…})
});
}); jest-cucumber doesn't currently support hooks that fire before and after each step, so this could look nicer if something like this were supported: const appUrl = process.env.HOMEPAGE URL
let appDriver = null;
defineFeature(RndHpyPath, test => {
test('Happy Path Scenario Test',({ given, when, then, beforeEachStep })=>{
beforeEachStep(async () => {
await withWebDriver(async (webDriver) => {
appDriver = new TGDriver({webDriver, appUrl});
});
});
given('Happy Path Scenario Precondition', async () => {
//Your test code goes here (appDriver will be populated now)
});
when('Happy Path Scenario Action and Condition', async () => {
//Your test code goes here (appDriver will be populated now)
});
then('Happy Path Scenario Action and Condition Validations', async() {…})
});
}); |
Thanks @bencompton, the way the tests works is, Basic Flow is like jest calls the
Please excuse me if any of it seems dumb/way to simple concept to understand. |
Hi,
I'm a newbie to javascript and nodejs. We have an existing (selenium-webdriver)script which needs to be reworked to fit jest-cucumber BDD style. Created a feature file and tried to modify the scripts to jest-cucumber step def style, but the catch is an additional withWebDriver function as shown below. withWebdriver is needed/used through out the test(jest test code below), but not sure how to divide code to fit given when then, due to the var/obj declarations scope restriction.
Doesn't Work
Facing no such (browser)session error here, after the given block.
This too doesn't work
Facing "Expected step #3 in scenario "Happy Path Scenario" to match "Happy Path Scenario"". Guess this related to feature file to step def mapping, which is disturbed by withWebDriver function.
Is there any way we can fit withWebDriver function to make it work throught out test with (given, when, then) not facing any scope restriction related errors.
Thanks.
The text was updated successfully, but these errors were encountered: