Last active
February 1, 2016 19:05
-
-
Save SthanleyLima/5da2c965f9b0fe94b96a to your computer and use it in GitHub Desktop.
Apresentação Calculadora Protractor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Report sem screenShot | |
var jasmineSpecReporterSetup = function() { | |
var SpecReporter = require('jasmine-spec-reporter'); | |
jasmine.getEnv().addReporter(new SpecReporter({ | |
displayFailuresSummary: true, //mostra resumo das falhas | |
displaysFailedSpec: true, //exibe os testes que falharam | |
displaySuiteNumber: true, //numero do teste na suite | |
displaySpecDuration: true //tempo de execução dos testes | |
})); | |
}; | |
//Report com screenShot | |
var jasmine2HtmlReporter = function() { | |
var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter'); | |
jasmine.getEnv().addReporter( | |
new Jasmine2HtmlReporter({ | |
savePath: 'reports' | |
}) | |
); | |
}; | |
//confiração de pastas | |
exports.config = { | |
seleniumAddress: 'http://localhost:4444/wd/hub', | |
// Framework usada | |
framework: 'jasmine2', | |
// arquivos que serão chamados | |
specs: ['*_spec.js'], | |
baseUrl: 'http://juliemr.github.io/protractor-demo', | |
//Rodando no Chrome | |
capabilities: { | |
//'browserName': 'chrome' | |
// rodando em Headless | |
'browserName': 'phantomjs', | |
"phantomjs.binary.path": require("phantomjs").path, | |
"phantomjs.ghostdriver.cli.args": ["--loglevel=DEBUG"] | |
}, | |
//melhorar o reports de retorno | |
onPrepare: jasmineSpecReporterSetup, | |
// opções de uso do Jasmine | |
jasmineNodeOpts: { | |
defaultTimeoutInterval: 30000 | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Created by https://www.gitignore.io/api/node | |
### Node ### | |
# Logs | |
logs | |
*.log | |
npm-debug.log* | |
# Runtime data | |
pids | |
*.pid | |
*.seed | |
# Directory for instrumented libs generated by jscoverage/JSCover | |
lib-cov | |
# Coverage directory used by tools like istanbul | |
coverage | |
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | |
.grunt | |
# node-waf configuration | |
.lock-wscript | |
# Compiled binary addons (http://nodejs.org/api/addons.html) | |
build/Release | |
# Dependency directory | |
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git | |
node_modules | |
## Custom | |
reports/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// helper.js | |
module.exports = { | |
verifyElementPresenceById : function(id) { | |
var elemento = $('#' + id); | |
expect(elemento.isDisplayed()).toBeTruthy(); | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "example", | |
"version": "1.0.0", | |
"description": "", | |
"main": "conf.js", | |
"scripts": { | |
"start": "webdriver-manager start", | |
"test": "protractor conf.js" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"jasmine": "^2.3.2", | |
"jasmine-spec-reporter": "^2.4.0", | |
"protractor-screenshot-reporter": "0.0.5", | |
"protractor-jasmine2-html-reporter": "0.0.5" | |
}, | |
"devDependencies": { | |
"karma": "^0.13.10", | |
"karma-phantomjs-launcher": "^0.2.1", | |
"phantomjs": "^1.9.18" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var paginaInicial = function(val1, val2) { | |
var campoInicial = element(by.model('first')); | |
var operador = element(by.model('operator')); | |
var campoFinal = element(by.model('second')); | |
var btGo = element(by.id('gobutton')); | |
var resultText = element(by.css('.ng-binding')); | |
campoInicial.sendKeys(val1); | |
campoFinal.sendKeys(val2); | |
return { | |
op: function(opCode) { | |
switch (opCode) { | |
case 0: | |
operador.element(by.css('option[value="ADDITION"]')).click(); | |
break; | |
case 1: | |
operador.element(by.css('option[value="SUBTRACTION"]')).click(); | |
break; | |
case 2: | |
operador.element(by.css('option[value="DIVISION"]')).click(); | |
break; | |
case 3: | |
operador.element(by.css('option[value="MULTIPLICATION"]')).click(); | |
break; | |
case 4: | |
operador.element(by.css('option[value="MODULO"]')).click(); | |
break; | |
default: | |
break; | |
} | |
btGo.click(); | |
return resultText.getText(); | |
} | |
} | |
}; | |
module.exports = paginaInicial; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var helper = require('./helper'); | |
var paginaInicial = require('./pageObject.js'); | |
describe('Testando Calculadora', function() { | |
it('Somando Valores', function() { | |
browser.get('/protractor-demo'); | |
var objeto = new paginaInicial(1, 1); | |
var resultado = objeto.op(0); | |
expect(resultado).toContain('2'); | |
}) | |
it('Subtraindo Valores', function() { | |
browser.get('/protractor-demo'); | |
var objeto = new paginaInicial(2, 1); | |
var resultado = objeto.op(1); | |
expect(resultado).toContain('1'); | |
}) | |
it('Dividindo Valores', function() { | |
browser.get('/protractor-demo'); | |
var objeto = new paginaInicial(4, 2); | |
var resultado = objeto.op(2); | |
expect(resultado).toContain('2'); | |
}) | |
it('Multiplicando Valores', function() { | |
browser.get('/protractor-demo'); | |
var objeto = new paginaInicial(4, 2); | |
var resultado = objeto.op(3); | |
expect(resultado).toContain('8'); | |
}) | |
it('Modulo de Valores', function() { | |
browser.get('/protractor-demo'); | |
var objeto = new paginaInicial(5, 3); | |
var resultado = objeto.op(4); | |
expect(resultado).toContain('2'); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment