2014-02-27 169 views
6

以下是來自angularjs e2e測試的一些代碼。瀏覽器對象將angularjs e2e測試轉換爲量角器

expect(browser().location().url()).toBe('/phones'); 

量角器出現此錯誤。

TypeError: Property 'browser' of object # is not a function

特別是,如何更改線來修復量角器誤差? 一般來說,我可以在哪裏找到webdriverjs瀏覽器對象上的文檔?

回答

8

您可以使用:

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

//or using baseUrl 
expect(browser.getCurrentUrl()).toEqual(browser.baseUrl + '/phones'); 

您可以找到API here

而這就是我使用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_: [] } 
相關問題