首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在angluarJS中,browser()对象定义在哪里?

在angluarJS中,browser()对象定义在哪里?
EN

Stack Overflow用户
提问于 2012-12-07 07:13:05
回答 2查看 4.6K关注 0票数 3

遵循Angular-phonecat教程,在scenario.js中的step-7使用了browser()和binding()对象,但是,当我尝试使用它们来测试我的应用程序时,运行testacular时说:

代码语言:javascript
复制
ReferenceError: browser is not defined
        at null.<anonymous> 

Intellij Ideal还说:未解析的函数或方法browser()。这里我漏掉了什么?

下面是本教程中的代码片段:“use strict”;

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

代码语言:javascript
复制
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');
    });
  });
});
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-12-07 07:25:03

它在angular-scenario.js中定义

票数 4
EN

Stack Overflow用户

发布于 2014-12-18 12:59:53

//Spec文件

代码语言:javascript
复制
'use strict';
describe('demoApp', function() {
it('should redirect node_list.html to node_list.html#/menu', function() {
browser().navigateTo('/node_list.html');
expect(browser().location().url()).toBe('/menu');
  });

describe('menu_view', function() {
beforeEach(function() {
  browser().navigateTo('/node_list.html#/menu'); 
});
});
});

Error:
Chrome 39.0.2171 (Linux) demoApp should redirect node_list.html to node_list.html#/menu FAILED
ReferenceError: browser is not defined at Object.<anonymous> (/test/viewpage.js:5:5)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13754336

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档