浏览器对象将angularjs e2e测试转换为量角器

Bil*_*rtz 6 angularjs protractor

这是来自angularjs e2e测试的一些代码.

expect(browser().location().url()).toBe('/phones');
Run Code Online (Sandbox Code Playgroud)

量角器给出了这个错误.

TypeError:对象#的属性"浏览器"不是函数

特别是,如何更改线以修复量角器错误?一般来说,我在哪里可以找到webdriverjs浏览器对象上的文档?

gle*_*tre 8

您可以使用:

//using full URL
expect(browser.getCurrentUrl()).toEqual('http://host:port/your/url/phones');

//or using baseUrl
expect(browser.getCurrentUrl()).toEqual(browser.baseUrl + '/phones');
Run Code Online (Sandbox Code Playgroud)

您可以在此处找到API.

这就是我使用时得到的console.log(browser);:

{ controlFlow: [Function],
  schedule: [Function],
  getSession: [Function],
  getCapabilities: [Function],
  getCapability: [Function],
  quit: [Function],
  actions: [Function],
  executeScript: [Function],
  executeAsyncScript: [Function],
  call: [Function],
  wait: [Function],
  sleep: [Function],
  getWindowHandle: [Function],
  getAllWindowHandles: [Function],
  getPageSource: [Function],
  close: [Function],
  getCurrentUrl: [Function],
  getTitle: [Function],
  findDomElement_: [Function],
  takeScreenshot: [Function],
  manage: [Function],
  navigate: [Function],
  switchTo: [Function],
  driver: 
   { session_: 
      { then: [Function: then],
        cancel: [Function: cancel],
        isPending: [Function: isPending] },
     executor_: { execute: [Function] },
     flow_: 
      { events_: {},
        timer: [Object],
        history_: [],
        activeFrame_: [Object],
        schedulingFrame_: [Object],
        eventLoopId_: [Object] } },
  element: { [Function] all: [Function] },
  '$': [Function],
  '$$': [Function],
  baseUrl: 'http://localhost:8000',
  rootEl: 'body',
  ignoreSynchronization: false,
  params: {},
  moduleNames_: [],
  moduleScripts_: [] }
Run Code Online (Sandbox Code Playgroud)