I use protractor with cucumber and whenever there is a need to switch between browser tabs with phantomjs it just hangs without any error message. However the same step works fine with Chrome browser. Why is that? My step is as follows
this.Then(/^the page url hash should be "([^"]*)"$/, function (arg1, callback) {
browser.getAllWindowHandles().then(function (handles) {
newWindowHandle = handles[2];
browser.switchTo().window(newWindowHandle).then(function () {
expect(browser.driver.getCurrentUrl()).to.eventually.contain(arg1).and.notify(callback);
});
});
Ok so apparently the issue was with
callback
. When i modified the above code slightly it works like a charm even in phantomjs!