当我调用 switchToWindow(handle): null value in entry: name=null 时出现以下错误
当我尝试切换并且句柄不为空或为空时,原始窗口仍然打开。这是我正在使用的代码:
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);