哪里浏览器()对象在angluarJS界定?浏览器、对象、angluarJS

2023-09-13 05:14:34 作者:)你给的罂粟花般的暧昧

继角phonecat教程,一步-7在scenario.js浏览器()和绑定()用于对象,但是,当我试图用它们来测试我的应用程序,运行testacular说:

 的ReferenceError:浏览器没有定义        在空<&匿名GT; 

另外的IntelliJ理想说道:无法解析函数或方法的浏览器()。我缺少的是在这里吗?

在这里从教程中的code片断:使用严格;

/ * http://docs.angularjs.org/guide/dev_guide.e2e-测试 * /

 描述('PhoneCat应用',函数(){  它('应该要的index.html index.html的#/电话重定向',函数(){    。浏览器()的NavigateTo(../../应用程序/ index.html的');    预计TOBE('/手机')(浏览器()位置()网址()。)。  });  描述(电话列表视图',函数(){    beforeEach(函数(){      。浏览器()的NavigateTo(../../应用程序/ index.html的#/手机'); //&下; ---浏览器()对象没有定义!!!    });    它('应该过滤的电话清单,用户键入搜索框',函数(){      期待(中继器(手机里。')计数()。)TOBE(20)。      。输入(查询)进入('关系');      期待(中继器(手机里。')计数()。)TOBE(1)。      。输入(查询)进入('摩托罗拉');      期待(中继器(手机里。')计数()。)TOBE(8)。    });    它('应该可以控制通过下拉选择框电话订购',函数(){      。输入(查询)进入('平板电脑'); //让我们缩小数据集,使测试断言短      期待(中继器('。电话里,电话列表)。列('phone.name'))。          toEqual([摩托罗拉XOOM \\ u2122具有Wi-Fi                   摩托罗拉XOOM \\ u2122]);      选择('orderProp')选项(字母)。      期待(中继器('。电话里,电话列表)。列('phone.name'))。          toEqual([摩托罗拉Xoom \\ u2122                   摩托罗拉XOOM \\ u2122具有Wi-Fi]);    });    它('应该使手机的具体环节',函数(){      。输入(查询)进入('关系');      。元素('。手机里一个')点击();      。期待(。浏览器()位置()网址())TOBE('/手机/ NEXUS-S');    });  });  描述(电话详细视图',函数(){    beforeEach(函数(){      。浏览器()的NavigateTo(../../应用程序/ index.html的#/手机/ NEXUS-S');    });    它('应显示与phoneId预留页',函数(){      期待(绑定(phoneId'))TOBE(NEXUS-S')。    });  });}); 

解决方案

它的角scenario.js中定义的

sqldbx怎么显示隐藏对象浏览器

Following the Angular-phonecat tutorial, step-7 in the scenario.js a browser() and binding() objects are used but, when I tried to use them to test my application, running testacular says:

ReferenceError: browser is not defined
        at null.<anonymous> 

Also Intellij Ideal says : unresolved function or method browser(). What am I missing here ?

here the code snippet from the tutorial: 'use strict';

/* http://docs.angularjs.org/guide/dev_guide.e2e-testing */

describe('PhoneCat App', function() {

  it('should redirect index.html to index.html#/phones', function() {
    browser().navigateTo('../../app/index.html');
    expect(browser().location().url()).toBe('/phones');
  });


  describe('Phone list view', function() {

    beforeEach(function() {
      browser().navigateTo('../../app/index.html#/phones'); //<---  browser() object is not defined !!! 
    });


    it('should filter the phone list as user types into the search box', function() {
      expect(repeater('.phones li').count()).toBe(20);

      input('query').enter('nexus');
      expect(repeater('.phones li').count()).toBe(1);

      input('query').enter('motorola');
      expect(repeater('.phones li').count()).toBe(8);
    });


    it('should be possible to control phone order via the drop down select box', function() {
      input('query').enter('tablet'); //let's narrow the dataset to make the test assertions shorter

      expect(repeater('.phones li', 'Phone List').column('phone.name')).
          toEqual(["Motorola XOOM\u2122 with Wi-Fi",
                   "MOTOROLA XOOM\u2122"]);

      select('orderProp').option('Alphabetical');

      expect(repeater('.phones li', 'Phone List').column('phone.name')).
          toEqual(["MOTOROLA XOOM\u2122",
                   "Motorola XOOM\u2122 with Wi-Fi"]);
    });


    it('should render phone specific links', function() {
      input('query').enter('nexus');
      element('.phones li a').click();
      expect(browser().location().url()).toBe('/phones/nexus-s');
    });
  });


  describe('Phone detail view', function() {

    beforeEach(function() {
      browser().navigateTo('../../app/index.html#/phones/nexus-s');
    });


    it('should display placeholder page with phoneId', function() {
      expect(binding('phoneId')).toBe('nexus-s');
    });
  });
});

解决方案

It's defined within angular-scenario.js