0
我正在寫一些使用webdriverJS的黃瓜測試。我試圖在每個場景之後使用一個後掛鉤來關閉瀏覽器窗口。問題是,該窗口將關閉,但不會重新打開。我得到的錯誤是它無法「找到」一個窗口。任何幫助或見解將不勝感激。掛鉤後關閉窗口,但不會重新打開下一個場景
這裏是我的.feature文件
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 "..."
這裏是我的hooks.js文件
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(); });
});
};
這裏是.js文件的前幾行文件
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();
});