每次我运行量角器命令时,baseurl会在启动实际测试规范之前重新加载多次。有时它会重新加载2次,有时会重新加载4-5次。
exports.config = {
plugins: [{
package: 'protractor-console',
logLevels: ['severe']
}],
allScriptsTimeout: 120000,
baseUrl: 'https://test.com/',
framework: 'jasmine2',
jasmineNodeOpts: {
isVerbose: true,
showColors: true,
includeStackTrace: true,
defaultTimeoutInterval: 100000,
},
multiCapabilities: [
{
browserName: 'chrome',
directConnect: true,
specs: [
'../specs/master_spec/master.js'
],
chromeOptions: {
args: ['--incognito', 'disable-extensions', 'start-maximized', 'show-fps-counter=true']
},
name: "chrome-tests",
shardTestFiles: true,
maxInstances: 4,
}
],
maxSessions: 1
};
Gmail注册流程规范文件: 首先它阻止,我试图从signupPage()函数调用该baseurl。我也使用了一些来自LoginModal.page文件的函数。
var users = require('../../config/users.js');
var conf = require('../../config/conf.js');
var LoginModal = require('../../pages/LoginModal.page.js');
var SignupModal = require('../../pages/SignupModal.page.js');
var ConnectDatabase = require('../../dbconnections/ConnectDatabase.js');
var dbscript = require('../../dbconnections/dbscript.js');
describe('QI : ', function() {
var page = new SignupModal();
page = new SignupModal();
var LoginPage = new LoginModal();
LoginPage = new LoginModal();
beforeEach (function(){
var dbqueries = new dbscript();
})
function signupPage() {
page.clickSignupOption();
};
function userIcon() {
browser.sleep(3000);
LoginPage.clickUsrIcon2();
};
function logout() {
LoginPage.clickLogoutOp();
};
describe('User : ', function() {
it('Signup with Gmail', function() {
signupPage();
browser.sleep(5000);
page.clickGoogleOption();
var winHandles = browser.getAllWindowHandles();
winHandles.then(function(handles) {
var parentWindow = handles[0];
var popUpWindow = handles[1];
browser.switchTo().window(popUpWindow);
browser.ignoreSynchronization = true;
browser.waitForAngular();
browser.sleep(6000);
//login to gmail on the pop up window
LoginPage.typeGmail(users.config.quantraLearner.userName);
LoginPage.clickNextBtn();
browser.sleep(3000);
LoginPage.enterPswd(users.config.quantraLearner.password);
LoginPage.clickpswdNextBtn();
browser.switchTo().window(parentWindow);
browser.sleep(10000);
browser.ignoreSynchronization = false;
expect(browser.getCurrentUrl()).toEqual(conf.config.baseUrl + 'dashboard');
userIcon();
logout();
expect(browser.getCurrentUrl()).toEqual(conf.config.baseUrl);
browser.sleep(5000);
});
});
});
});