测试当中时常会有需要先储存後检查的动作,如此就要先开好两个视窗,不管是新分页或新视窗,一个作为编辑页面,一个则作为检查页面。如果是每编辑一个地方就需要检查,最方便快速就是有两个视窗来回切换检查。
openWindow()
其实 Nightwatch 中并没有可以直接开新视窗或新分页的方式,可是我们可以利用原生的 Javascript 建立:
window.open(strUrl, strWindowName, [strWindowFeatures]);
举例而言,如果要在新分页中开启 google search
window.open('https://www.google.com/', '_blank');
新视窗则是
window.open('https://www.google.com/', null, 'height=1024, width=768');
後面的 height, width 为视窗大小
透过 Nightwatch 的 execute 方式执行则会变成:
.execute(
function(newWindow) {
window.open(newWindow, null, 'height=1024,width=768');
},
[url],
);
当然也可以包成客制化指令:
module.exports = {
command: async function(url) {
this.execute(
function(newWindow) {
window.open(newWindow, null, 'height=1024,width=768');
},
[url],
);
},
};
如此一来,我们就可以先开启视窗 -> 切换视窗的方式验证了~
browser.openWindow(testURL)
browser.windowHandles(function(result) {
browser.switchWindow(result.value[1]);
// Verify
browser.switchWindow(result.value[0]);
}
<<: [17] [烧瓶里的部落格] 07. 专案可安装化(打包)
>>: Day 16 网页分析 - Web Application Analysis (网页内容扫描器 - DIRB )
前言 昨天已经在storyboard上将tableView连结上程序中的table,不过并没有解释到...
Chatbot integration- 多功能 chatbot 就此诞生! 终於到了这一步,要把所...
前言 为什麽要把 debug 拿出来说呢? 我发现其实 debug 的流程比较少人讨论, 一般我们会...
今天念 重新认识 Vue.js | Kuro Hsu 2-2 元件之间的沟通传递 在 HTML 里的...
前言 我们今天还是没有离开 user_bp,我们要来弄写文章的页面,也就是 markdown 上场的...