I am writing some cucumber tests using webdriverJS. I am trying to use an after hook to close the browser window after each scenario. The problem is, the window will close but not re-open. The error I get is that it cannot "find" a window. Any help or insight will be greatly appreciated.
Here is my .feature file
Background
Given I go to the website "..."
Scenario: One
When I click() on "..."
When I getText() of the title "..."
Then the title should be "..."
Scenario: Two
When I click() on "..."
When I getText() of the title "..."
Then the title should be "..."
Here is my hooks.js file
var ID = null;
module.exports = function(){
this.After( function (err, next){
client
.getCurrentTabId( function(err, tabID){
ID = tabID;
expect(err).to.be.null;
next() })
.close( ID, function(err){
console.log('-------------CLOSE-------------');
next(); });
});
};
Here are the first few lines of the .js file
client = webdriverjs.remote({ desiredCapabilities: {browserName: 'safari'}, logLevel:
'verbose'});
module.exports = function()
{
client.init();
this.Given(/^I go to the website "([^"]*)"$/, function (url, next){
client
.url(url)
console.log("BACKGROUND STATEMENT");
next();
});