-
-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
596c617
commit 69e3d60
Showing
25 changed files
with
552 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# EditorConfig helps developers define and maintain consistent | ||
# coding styles between different editors and IDEs | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
|
||
# Change these settings to your own preference | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
# We recommend you to keep these unchanged | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
env: | ||
projectname: "myProject" | ||
baseUrl: "http://localhost:8080/test/site/" | ||
|
||
selenium: | ||
host: 0.0.0.0 | ||
port: 4444 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"name": "cucumber-boilerplate", | ||
"version": "0.0.0", | ||
"description": "Boilerplate project to run WebdriverIO tests with Cucumber", | ||
"homepage": "https://github.com/webdriverio/cucumber-boilerplate", | ||
"main": "test/runner.js", | ||
"scripts": { | ||
"test": "mocha" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/webdriverio/cucumber-boilerplate.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/webdriverio/cucumber-boilerplate/issues" | ||
}, | ||
"keywords": [ | ||
"webdriverio", | ||
"cucumber", | ||
"test", | ||
"selenium" | ||
], | ||
"author": "Christian Bromann <christian@saucelabs.com>", | ||
"license": "MIT", | ||
"dependencies": { | ||
"chai": "~1.9.0", | ||
"config": "^1.8.1", | ||
"http-server": "^0.7.3", | ||
"mocha": "^1.18.2", | ||
"webdriverio": "^2.3.0", | ||
"yadda": "^0.10.14", | ||
"yaml": "^0.2.3" | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--reporter spec | ||
--timeout 100000 | ||
--require chai | ||
|
||
./test/runner.js |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
var Yadda = require('yadda'), | ||
config = require('config').env, | ||
should = require('chai').should(), | ||
beforeHook = require('./support/hooks/before.js'), | ||
afterHook = require('./support/hooks/after.js'), | ||
beforeEachHook = require('./support/hooks/beforeEach.js'), | ||
afterEachHook = require('./support/hooks/afterEach.js'), | ||
context = config, | ||
processed = 0, | ||
fileCount = null, | ||
currentStep; | ||
|
||
|
||
/** | ||
* expose assertion library | ||
*/ | ||
context.expect = chai.expect; | ||
context.assert = chai.assert; | ||
|
||
Yadda.plugins.mocha.AsyncScenarioLevelPlugin.init(); | ||
|
||
new Yadda.FeatureFileSearch('./test/features').each(function(file,i,files) { | ||
fileCount = fileCount === null ? files.length : fileCount; | ||
|
||
featureFile(file, function(feature) { | ||
|
||
if(feature.annotations.pending) { | ||
fileCount--; | ||
} | ||
|
||
before(function(done) { | ||
|
||
if(processed === 0) { | ||
return beforeHook(beforeEachHook.bind(null,done)); | ||
} | ||
|
||
beforeEachHook(done); | ||
}); | ||
scenarios(feature.scenarios, function(scenario, done) { | ||
var stepDefinitions = require('./support/step-definitions'); | ||
var yadda = new Yadda.Yadda(stepDefinitions, context); | ||
yadda.yadda(scenario.steps, done); | ||
}); | ||
|
||
Yadda.EventBus.instance().on(Yadda.EventBus.ON_EXECUTE, function(event) { | ||
currentStep = event.data.step; | ||
}); | ||
|
||
after(function(done) { | ||
|
||
if(++processed === fileCount) { | ||
return afterEachHook(afterHook.bind(null,done)); | ||
} | ||
|
||
afterEachHook(done); | ||
|
||
}); | ||
|
||
}); | ||
|
||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* check content for specific element or input field | ||
*/ | ||
|
||
module.exports = function(type, element, falseCase, origText, done) { | ||
var command = type !== 'inputfield' ? 'getText' : 'getValue'; | ||
browser[command](element, function(err, text) { | ||
should.not.exist(err); | ||
|
||
if(falseCase) { | ||
origText.should.not.equal(text); | ||
} else { | ||
origText.should.equal(text); | ||
} | ||
|
||
}) | ||
.call(done); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* check cookie content | ||
*/ | ||
|
||
module.exports = function (obsolete ,name, falseCase, value, done) { | ||
browser.getCookie(name, function(err,cookie) { | ||
should.not.exist(err); | ||
cookie.name.should.equals(name, 'no cookie found with the name "' + name + '"'); | ||
|
||
if(falseCase) { | ||
cookie.value.should.not.equal(value, 'expected cookie "' + name + '" not to have value ' + value); | ||
} else { | ||
cookie.value.should.equal(value, 'expected cookie "' + name + '" to have value ' + value + ' but got ' + cookie.value); | ||
} | ||
}).call(done); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* check cookie content | ||
*/ | ||
|
||
module.exports = function (obsolete ,name, falseCase, done) { | ||
browser.getCookie(name, function(err,cookie) { | ||
should.not.exist(err); | ||
|
||
if(falseCase) { | ||
expect(cookie).to.be.null; | ||
} else { | ||
expect(cookie).not.to.be.null; | ||
} | ||
}).call(done); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* check width and height | ||
*/ | ||
|
||
module.exports = function(elem) { | ||
|
||
var done = arguments[arguments.length-1], | ||
width = null, | ||
height = null, | ||
falseCaseWidth,falseCaseHeight; | ||
|
||
if(arguments.length === 6) { | ||
falseCaseWidth = arguments[1] === 'nicht die'; | ||
falseCaseHeight = arguments[3] === 'nicht die'; | ||
width = parseInt(arguments[2],10); | ||
height = parseInt(arguments[4],10); | ||
} else if(arguments[2] === 'Breite') { | ||
falseCaseWidth = arguments[1] === 'nicht die'; | ||
width = parseInt(arguments[3],10); | ||
} else { | ||
falseCaseHeight = arguments[1] === 'nicht die'; | ||
height = parseInt(arguments[3],10); | ||
} | ||
|
||
browser.getElementSize(elem, function(err,res) { | ||
should.not.exist(err); | ||
|
||
if(width) { | ||
if(falseCaseWidth) { | ||
res.width.should.not.equal(width, 'Element ' + elem + ' sollte nicht ' + width + 'px breit sein'); | ||
} else { | ||
res.width.should.equal(width, 'Element ' + elem + ' sollte ' + width + 'px breit sein, ist jedoch ' + res.width + ' breit'); | ||
} | ||
} | ||
|
||
if(height) { | ||
if(falseCaseHeight) { | ||
res.height.should.not.equal(height, 'Element ' + elem + ' sollte nicht ' + height + 'px hoch sein'); | ||
} else { | ||
res.height.should.equal(height, 'Element ' + elem + ' sollte ' + height + 'px hoch sein, ist jedoch ' + res.height + ' hoch'); | ||
} | ||
} | ||
|
||
}).call(done); | ||
|
||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* check if element exists | ||
*/ | ||
|
||
module.exports = function (isExisting, elem, done) { | ||
isExisting = isExisting === 'a'; | ||
|
||
browser.elements(elem, function(err,res) { | ||
should.not.exist(err); | ||
|
||
if(isExisting) { | ||
expect(res.value).to.have.length.above(0, 'element with selector "' + elem + '" should exist on the page'); | ||
} else { | ||
expect(res.value).to.have.length(0, 'element with selector "' + elem + '" should not exist on the page'); | ||
} | ||
}).call(done) | ||
|
||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* check position | ||
*/ | ||
|
||
module.exports = function(elem) { | ||
|
||
var done = arguments[arguments.length-1], | ||
x = null, | ||
y = null, | ||
falseCaseX,falseCaseY; | ||
|
||
if(arguments.length === 6) { | ||
falseCaseX = arguments[1] === ' nicht'; | ||
falseCaseY = arguments[3] === ' nicht'; | ||
x = parseInt(arguments[2],10); | ||
y = parseInt(arguments[4],10); | ||
} else if(arguments[1] === 'x') { | ||
falseCaseX = arguments[2] === ' nicht'; | ||
x = parseInt(arguments[3],10); | ||
} else { | ||
falseCaseY = arguments[2] === ' nicht'; | ||
y = parseInt(arguments[3],10); | ||
} | ||
|
||
browser.getLocation(elem, function(err,res) { | ||
should.not.exist(err); | ||
|
||
if(x) { | ||
if(falseCaseX) { | ||
res.x.should.not.equal(x, 'Element ' + elem + ' sollte nicht mit ' + x + 'px auf der x Achse liegen'); | ||
} else { | ||
res.x.should.equal(x, 'Element ' + elem + ' sollte mit ' + x + 'px auf der x Achse liegen, ist jedoch bei ' + res.x); | ||
} | ||
} | ||
|
||
if(y) { | ||
if(falseCaseY) { | ||
res.y.should.not.equal(y, 'Element ' + elem + ' sollte nicht mit ' + y + 'px auf der y Achse liegen'); | ||
} else { | ||
res.y.should.equal(y, 'Element ' + elem + ' sollte mit ' + y + 'px auf der y Achse liegen, ist jedoch bei ' + res.y); | ||
} | ||
} | ||
|
||
}).call(done); | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* check attribute or css property | ||
*/ | ||
|
||
module.exports = function(isCSS, attrName, elem, falseCase, value, done) { | ||
var command = isCSS ? 'getCssProperty' : 'getAttribute'; | ||
|
||
browser[command](elem, attrName, function(err,res) { | ||
should.not.exist(err); | ||
|
||
if(falseCase) { | ||
res.should.not.equal(value, (isCSS ? 'CSS ' : '') + 'Attribut des Elementes ' + elem + ' sollte nicht den Wert ' + res + ' besitzen'); | ||
} else { | ||
res.should.equal(value, (isCSS ? 'CSS ' : '') + 'Attribut des Elementes ' + elem + ' sollte nicht den Wert ' + res + ' besitzen, sondern ' + value); | ||
} | ||
}).call(done); | ||
|
||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* check if element is selected | ||
*/ | ||
|
||
module.exports = function (element, falseCase, done) { | ||
browser.isSelected(element, function(err,isSelected) { | ||
should.not.exist(err); | ||
|
||
if(falseCase) { | ||
isSelected.should.not.equal(true, element + ' should not be selected'); | ||
} else { | ||
isSelected.should.equal(true, element + ' should be selected'); | ||
} | ||
}).call(done); | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* check title | ||
*/ | ||
|
||
module.exports = function (falseCase, docTitle, done) { | ||
|
||
browser.getTitle(function(err, title) { | ||
should.not.exist(err); | ||
|
||
if(falseCase) { | ||
title.should.not.equal(docTitle, 'expected title not to be ' + docTitle); | ||
} else { | ||
title.should.equal(docTitle, 'expected title to be "' + docTitle + '" but found "' + title + '"'); | ||
} | ||
|
||
}).call(done); | ||
|
||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* check url | ||
*/ | ||
|
||
module.exports = function (falseCase, url, done) { | ||
|
||
browser.url(function(err,result) { | ||
should.not.exist(err); | ||
|
||
if(falseCase) { | ||
result.value.should.not.equal(url, 'expected url not to be ' + result.value); | ||
} else { | ||
result.value.should.equal(url, 'expected url to be "' + result.value + '" but found "' + url + '"'); | ||
} | ||
|
||
}).call(done); | ||
|
||
}; |
Oops, something went wrong.