nightwatch 切换窗口

.switchWindow()

Change focus to another window. The window to change focus to may be specified by its server assigned window handle, or by the value of its name attribute.

To find out the window handle use window_handles protocol action

Parameters:
NameTypedescription
handleOrName string The server assigned window handle or the name attribute.
callback
Optional
function Optional callback function to be called when the command finishes.
Usage:
 this.demoTest = function (browser) {
   browser.window_handles(function(result) {
     var handle = result.value[0]; //获取第一个窗口句柄
     browser.switchWindow(handle);
   });
 };

  

 

 

posted on 2018-01-29 12:55  清明-心若淡定  阅读(382)  评论(0编辑  收藏  举报