0

I am using cucumberjs, @wdio/cucumber-framework(version:7.16.13), wdio(version: 7.16.13) along with javascript.

Due to some issue I have to define before hook of wdio in my step definition file(mystepdefinition.js):

mystepdefinition.js:

    import { Before } from '@wdio/cucumber-framework';
    ...
    Before( function(capabilities, specs, browser){
        console.log("*******************************************");      
        console.log("capabilities:"+JSON.stringify(capabilities));
        console.log("specs:"+specs);
        console.log("browser:"+browser);
        
        console.log("*******************************************");      
    });

other step definitions...

Output:

capabilities: very long json object containing all details of feature file and its scenarios

specs:

(error, result) => {
                if (value_checker_1.doesHaveValue(error)) {
                     reject(error);
                 }
                 else {
                     resolve(result);
                 }
             }

browser:undefined

Here it is printing value of browser as undefined. It is printing some value of capabilities and specs though these values are also weird.

But my question here is why value for browser is undefined? Actually my main motive here is to get the name of scenario currently running. Can anybody tell me the solution?

Edit: Please note that we define hooks generally in wdio.conf.js file where hook name is before. But when we define hook in step definition by importing them from @wdio/cucumber-framework then its name is Before. Note the first letter b. If I use the before hook in wdio.conf.js then it prints proper values of all 3 parameters but not when I use Before hook in step definition file.

a Learner
  • 4,944
  • 10
  • 53
  • 89

0 Answers0