【问题标题】:Getting AngularJS Scope in Nightwatch在 Nightwatch 中获取 AngularJS 范围
【发布时间】:2018-09-25 22:25:18
【问题描述】:

我是 Nightwatch 的新手,我只是想知道如何在 Nightwatch 中获取 AngularJS 元素。

有没有办法完成这个任务?

【问题讨论】:

  • 拜托,更好地描述你的问题,把一些代码作为例子,因为旅游问题不清楚。

标签: angularjs scope


【解决方案1】:
    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)
    });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-02-04
    • 2015-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多