Я использую Nightwatch для написания своих тестов. В моей странице объекта у меня есть «раздел». В этом разделе есть команды, но когда я вызываю команды в тесте, он возвращает «раздел не является функцией». пожалуйста, найдите объект моей страницы и проверьте ниже.
Page Object
sections:{
Profile:{
myprofile:'#myprofile',
elements:{
firstName:{
selector:'//a [contains(text(),\'firstName\')]',
locateStrategy:'xpath'
}
},
commands:[{
clickRedeem(){
return this
.click('@myprofile')
},
clickMerchandise(){
return this
.click('@firstName')
}
}]
}
},
В тесте я вызываю команду, подобную этой
this.profileTest.section('@myprofile').clickProfile(); but its returning
this.profileTest.section is not a function
Я пытался, как вы упомянули. пожалуйста, найдите детали ниже.
redeemMenu:{
selector:'#myprofile',
elements:{
merchandiseMenu:{
selector:'//a [contains(text(),\'Merchandise\')]',
locateStrategy:'xpath'
},
},
commands:[{
clickRedeem(){
return this
.waitForElementVisible('@redeemMenu')
.click('@redeemMenu')
},
clickMerchandise(){
return this
.waitForElementVisible('@merchandiseMenu')
.click('@merchandiseMenu')
},
}]
},
test
var profileSection = await this.profileTest.section.redeemMenu
profileSection.clickRedeem()
Error: Element "redeemMenu" was not found in "redeemMenu". Available
elements: merchandiseMenu