Browser switch handle Phantomjs Issue

222 Views Asked by At

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);
        });
    });
1

There are 1 best solutions below

0
On

Ok so apparently the issue was with callback. When i modified the above code slightly it works like a charm even in phantomjs!

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.getCurrentUrl()).to.eventually.contain(arg1);
            });
        });
        callback();

  });