Nightmare.js FOR循环

时间:2018-06-11 09:53:10

标签: javascript node.js loops nightmare

我在数组(JSON)中删除了一些数据,我需要在所有条目中使用噩梦进行循环自动填充... 我不知道如何在梦魇实例中制作循环。

var nightmare =梦魇({show:true}); 恶梦

.wait(5000)
.goto('http://www.example.com')
.wait('#USER')
.type('#USER', 'xyxyxy')
.wait('#PASSWORD')
.type('#PASSWORD', 'xyxyxyxy')
.click('#Submit')


.wait('#mySidenav > accordion > accordion-group:nth-child(2) > div > div.panel-collapse.collapse > div > div > accordion > accordion-group:nth-child(1) > div > div.panel-collapse.collapse > div > div:nth-child(1) > div > ul > li > a')
.click('#mySidenav > accordion > accordion-group:nth-child(2) > div > div.panel-collapse.collapse > div > div > accordion > accordion-group:nth-child(1) > div > div.panel-collapse.collapse > div > div:nth-child(1) > div > ul > li > a')



//I want for loop start here
.wait('#ctl00_ctl00_SiteMasterContent_NavigationBar1_rgNew_rbNewAvailableLoad_Text')
.click('#ctl00_ctl00_SiteMasterContent_NavigationBar1_rgNew_rbNewAvailableLoad_Text')

.wait(5000)
.wait('#SiteMasterContent_PageContent_ctl00_ctl00_SiteMasterContent_PageContent_chkBrokerablePanel > span > label') UNCHECK
.click('#SiteMasterContent_PageContent_ctl00_ctl00_SiteMasterContent_PageContent_chkBrokerablePanel > span > label')
.wait(2000 ) //wait refreshing fields
.type('#SiteMasterContent_PageContent_txtContactNumber','XXX XXX XXX') 
.click('#NEXT')

// for loop end

.end()

有办法将所有噩梦放在循环中,但我只需要一个部分循环......任何想法如何做到这一点?感谢...

0 个答案:

没有答案