我们正在使用Protractor来测试我们的Angular网站。我们的E2E测试在PC版本上运行良好。现在我想设置测试以在Android上使用Selendroid运行。我按照https://github.com/angular/protractor/blob/master/docs/mobile-setup.md的设置指南运行Android模拟器,这是我的量角器配置:
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
allScriptsTimeout: 120000,
specs: [
'login.test.js'
],
capabilities: {
'browserName': 'android',
emulator: true
},
baseUrl: 'my web site',
framework: 'jasmine2',
jasmineNodeOpts: {
defaultTimeoutInterval: 300000,
},
onPrepare: function () {
var wd = require('wd'),
protractor = require('protractor'),
wdBridge = require('wd-bridge')(protractor, wd);
wdBridge.initFromProtractor(exports.config);
wdBrowser.context('WEBVIEW');
//helper functions
global.helpers = require('./helper.js');
//prepare spec host map
global.helpers.prepareSpecHostMap();
//extend protractor
global.helpers.extendProtractor();
}
};
这是我的测试套件:
describe('Test login and logout (min-suite)', function () {
beforeAll(function () {
global.helpers.setHostParameters('login');
});
it('test login and logout success', function () {
global.helpers.login(global.host.testUser, global.host.testPassword);
expect(browser.getLocationAbsUrl()).toMatch('/home');
element(by.id('userButtonGroup')).click();
element(by.id('logoutButton')).click();
expect(browser.getLocationAbsUrl()).toMatch('/login');
});
});
当我运行测试时,我面临类似的issue。我已经通过这样一个简单的测试快速测试了:
it('test login and logout success', function () {
browser.driver.get('my web site');
});
工作正常。有人可以指导我做我错过的测试工作吗?