2017-04-04 46 views
1

我正嘗試編寫一個代碼,用於使用量角器將其重定向到index.html文件。當我輸入終端量角器protractor.conf.js以執行e2e測試時。它表明我這個錯誤:量角器不推薦使用getLocationAbsUr

W /量角器 - browser.getLocationAbsUrl()已過時,請使用browser.getCurrentUrl代替。

爲什麼會這樣呢?是不是getLocationAbsUrl量角器的話?

的配置量角器

exports.config = { 
    allScriptsTimeout: 11000, 
    specs: [ 
    'e2e/*.js' 
     ], 
    capabilities: { 
    'browserName': 'chrome' 
    }, 

baseUrl: 'http://localhost:3000/', 

framework: 'jasmine', 
directConnect: true, 

jasmineNodeOpts: { 
    defaultTimeoutInterval: 30000 
} 
}; 

代碼的代碼,E2E測試

'use strict'; 

describe('conFusion App E2E Testing', function() { 

    it('should automatically redirect to/when location hash/fragment is empty', function() { 

    browser.get('index.html'); 
    expect(browser.getLocationAbsUrl()).toMatch("/"); 

}); 
+0

'expect(browser.getCurrentUrl())。toMatch(「/」);'Use this –

回答

1

由於您的錯誤說,這個功能是deprecated。這意味着現在不鼓勵使用此代碼。你應該使用getCurrentUrl()

Protractor's Github

browser.getLocationAbsUrl()現在已經過時,你應該使用 browser.getCurrentUrl()代替。