切换到新窗口后,只有' urlContains'工作中。
没有其他事情发生(无论是click还是elementVisible或其他任何东西)
守夜人的部分代码:
'Order Module' : function(browser) {
browser
.useXpath()
.waitForElementVisible("@OrderTab", 20000)
.pause(5000)
.click("@OrderTab")
.pause(5000)
.useCss()
.waitForElementVisible("input[title = 'New']", 20000)
.click("input[title = 'New']")
.useXpath()
.waitForElementVisible("@OrderTextBox']", 20000)
.verify.urlContains('https://invoiceit-s.na30.visual.force.com/apex/createJobStep1?retURL=%2Fa0K%2Fo&save_new=1&sfdc.override=1')
.setValue("@OrderTextBox", "Order Name")
.pause(10000)
.click("@LinkIconForNewWindow")
.pause(10000)
.window_handles(function(result) {
this.verify.equal(result.value.length, 2, '2 windows should be open')
var handle = result.value[1]
this.switchWindow(handle)
this.verify.urlContains('https://invoiceit-s.na30.visual.force.com/_ui/common/data/LookupPage?lkfm=j_id0%3AjobForm&lknm=j_id0%3AjobForm%3Apb%3Arender%3Aj_id38%3A0%3Aj_id39&lktp=001&lksrch=')
this.useXpath()
this.waitForElementVisible("@searchBox", 20000)
})
.pause(20000)
.end() }
答案 0 :(得分:0)
我不熟悉Xpath,你能发布元素块的丝网印刷吗?可能是我可以帮到你
PS:不要使用太多的暂停(),它会减慢你的测试程序,守夜人会每隔500毫秒检查一次元素。
编辑1:问题可能是因为'@searchBox
'元素,在点击弹出式按钮后,这是否在浏览器的第一个标签中?如果是,那应该是:
.window_handles(function(result) {
var home = result.value[0], // your first tab
handle = result.value[1]; // second tab
this
.switchWindow(handle)
.verify.urlContains('https://invoiceit')
.useXpath()
.switchWindow(home) // you need to switch back to first tab , even you close the pop-up.
.waitForElementVisible("@searchBox", 20000)
})
PS:我在这篇文章中的回答可能有所帮助。Loop is not working properly - nightwatch