I'm getting the following error when I call switchToWindow(handle): null value in entry: name=null
The original window is still open when I try to switch and handle is not null or empty. Here is the code I'm using:
var session = this.remote;
var handle;
return session
.get('http://www.google.com')
.getCurrentWindowHandle()
.then(function (currentHandle) {
console.log('handle: ' + currentHandle);
handle = currentHandle;
})
.execute(function() {
var newWindow = window.open('https://www.instagram.com/', 'insta');
})
.switchToWindow('insta')
.closeCurrentWindow()
.then(function () {
console.log('old handle: ' + handle);
})
.sleep(2000)
.switchToWindow(handle);