On Hooks the "driver" object is null
vhugogarcia opened this issue · 0 comments
Hello friends,
I'm trying to load a page and perform a login action under a Hook before run the actual feature so I can login multiple users from the Hook based on Tags. Since multiple backgrounds are not allowed on features by cucumber, I was thinking on this solution.
when trying to implement it, I'm trying to load a url using the helper or directly using driver.get ,however, it fires an error:
TypeError: node_modules/selenium-cucumber-js/node_modules/cucumber/lib/cucumber/support_code/library.js:17 Cannot read property 'get' of null
Anybody has any idea about how to fix this?
My Hook code is:
/* * Adds a before feature hook */ this.BeforeFeature(function(feature, done) { feature.getTags().forEach(function (tag) { // Only features for Client Access if(tag.getName() === '@user-01') { // load the url and wait for it to complete driver.get("https://google.com/").then(function() { // now wait for the body element to be present return driver.wait(until.elementLocated(by.css('body')), 10000); }); } }); done(); });