我使用nightwatchjs自动提交支持表单。使用nightwatchjs单击链接将在新窗口中打开表单页面。如何在该窗口上设置焦点?任何帮助都是非常感谢的。
发布于 2015-05-28 04:35:59
使用switchWindow命令。https://nightwatchjs.org/api/switchWindow.html
发布于 2018-11-13 23:34:25
我试着用代码的例子给你一个更详细的解释。目前我使用的是chromedriver 2.43.1 (与npm一起安装)、selenim standalone 3.141.5和nigtwatch 0.9.21。
module.exports = {
'Test new tab open': function (browser) {
browser.url('http://localhost:8000')
.click('#a-href-with-target-blank')
// Switch to new tab
browser.window_handles(function (result) {
// 0 == current main window, 1 == new tab
var handle = result.value[1];
browser.switchWindow(handle);
});
// do something
browser.closeWindow(); // Close tab
// Switch to main window
browser.window_handles(function (result) {
// 0 == current main window, 1 == new tab
var handle = result.value[0];
browser.switchWindow(handle);
});
}
};希望能有所帮助。
https://stackoverflow.com/questions/30483327
复制相似问题