Skip to content

Instantly share code, notes, and snippets.

@MSakamaki
Created May 28, 2015 11:53
Show Gist options
  • Save MSakamaki/705b9ec14792db4a6851 to your computer and use it in GitHub Desktop.
Save MSakamaki/705b9ec14792db4a6851 to your computer and use it in GitHub Desktop.
Protractor Helper Memo
// Protractor configuration
// https://github.com/angular/protractor/blob/master/docs/referenceConf.js
'use strict';
var q = require('q');
var fs = require('fs');
var path = require('path');
String.prototype.toCamelCase = function(){
return this.split('-')
.map(function(v,i){
if (i===0) {
return v;
}else{
return v[0].toUpperCase() + v.substr(1, v.length - 1);
}
})
.join('');
};
exports.config = {
//...
// コンポーネント設定(todo helper)
onPrepare : function(){
browser.driver.manage().window().setSize(1280, 720);
// 指定フォルダから特定の命名規則でpoを自動吸い上げ。
var base = './e2e/components/';
var PageObject = {};
var deferred = q.defer();
fs.readdir(base, function(err, files){
if (err) {
throw err;
}
files.filter(function(file){
return fs.lstatSync(base+file).isDirectory();
}).forEach(function (file) {
console.log(file.toCamelCase(),':',path.join(__dirname, 'components', file, file +'.po'))
PageObject[file.toCamelCase()] =
require(path.join(__dirname, 'components', file, file +'.po'));
});
global.po = PageObject;
deferred.resolve();
});
return deferred.promise;
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment