【发布时间】:2016-04-27 18:00:51
【问题描述】:
当我调用 switchToWindow(handle) 时出现以下错误: 条目中的空值: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);
【问题讨论】: