2017-04-04 50 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()代替。