【发布时间】:2018-09-25 22:25:18
【问题描述】:
我是 Nightwatch 的新手,我只是想知道如何在 Nightwatch 中获取 AngularJS 元素。
有没有办法完成这个任务?
【问题讨论】:
-
拜托,更好地描述你的问题,把一些代码作为例子,因为旅游问题不清楚。
我是 Nightwatch 的新手,我只是想知道如何在 Nightwatch 中获取 AngularJS 元素。
有没有办法完成这个任务?
【问题讨论】:
const getElementScope = (selector) => {
cy.get(selector)
.then(($el) => {
cy.window()
.its('angular')
.then((ng) => {
console.log(ng.element($el).scope())
console.log("ng.element($el)", ng.element($el))
})
})
}
在 cypress 中,我们可以像这样获得角度范围,有没有办法获得角度范围。
我尝试低于 2,但它说范围和角度不是函数:
1)browser.execute(function(){
return $('#maincontent > div.container-fluid').scope();
}, ['title'], function(result){
console.log(result)
});
2)browser.execute(function(){
return angular.element($('#maincontent > div.container-fluid')).scope();
}, ['title'], function(result){
console.log(result)
});
【讨论】: