Skip to content

Commit 1507fc1

Browse files
author
Kevin Laurier
committed
Initial commit.
Tests aren't running yet due to a bug with Protractor (see angular/protractor#2456 (comment))
0 parents  commit 1507fc1

File tree

10 files changed

+203
-0
lines changed

10 files changed

+203
-0
lines changed

.idea/.name

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/ProtCuke.iml

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

features/examples.feature

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Feature: Example feature
2+
3+
Scenario Outline: Wanderlust App
4+
Given I am on the Wanderlust website
5+
When I search for city "<destination>"
6+
Then I should see a results dropdown
7+
And I should get <num> results
8+
9+
Examples:
10+
| destination | num |
11+
| berlin | 5 |
12+
| montreal | 5 |
13+
| timbuktu | 1 |
14+
| gdansk | 4 |
15+
| fdsafr | 0 |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Created by kev on 24/08/15.
3+
*/
4+
5+
var utils = require('./utils');
6+
7+
var Wanderlust = function(world) {
8+
this.world = world;
9+
this.url = 'http://mywanderlust.co/';
10+
};
11+
12+
Wanderlust.prototype.go = function(callback) {
13+
//return this.world.browser.get(this.url);
14+
};
15+
16+
Wanderlust.prototype.search = function(callback) {
17+
/*
18+
utils.findByModel(this.world, "chosenPlace", function(result) {
19+
result.sendKeys(destination).then(callback);
20+
})
21+
*/
22+
//return this.world.browser.findElement(this.by.model(item));
23+
return Promise.resolve(1);
24+
};
25+
26+
Wanderlust.prototype.hasSearchDropdown = function() {
27+
var numElements = this.world.browser.findElements(this.world.by.css(".pac-container")).length;
28+
console.log(numElements);
29+
return Promise.resolve(numElements == 1);
30+
};
31+
32+
module.exports = Wanderlust;
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* Created by kev on 23/08/15.
3+
*/
4+
5+
var Utils = function(){
6+
};
7+
8+
Utils.prototype.get = function(sut, url, callback) {
9+
return sut.browser.get(url);
10+
};
11+
12+
Utils.prototype.findByModel = function(sut, item, callback) {
13+
sut.browser.findElement(sut.by.model(item)).then(function(result) {
14+
callback(result);
15+
});
16+
};
17+
18+
Utils.prototype.findByBinding = function(sut, item, callback) {
19+
sut.browser.findElement(sut.by.binding(item)).then(function(result) {
20+
callback(result);
21+
});
22+
};
23+
24+
Utils.prototype.isLinkPresent = function(sut, find, callback) {
25+
sut.browser.isElementPresent(sut.by.linkText(find)).then(function(result) {
26+
callback(result);
27+
});
28+
};
29+
30+
Utils.prototype.isElementPresentByClass = function(sut, find, callback) {
31+
sut.browser.isElementPresent(sut.by.css('.'+find)).then(function(result) {
32+
callback(result);
33+
});
34+
};
35+
36+
Utils.prototype.getElementByClass = function(sut, find, callback) {
37+
sut.browser.findElement(sut.by.css('.'+find)).then(function(result) {
38+
callback(result);
39+
});
40+
};
41+
42+
Utils.prototype.getElementsByClass = function(sut, find, callback) {
43+
sut.browser.findElements(sut.by.css('.'+find)).then(function(result) {
44+
callback(result);
45+
});
46+
};
47+
48+
module.exports = Utils;

features/step_definitions/my_steps.js

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
var pc = require('protractor-cucumber');
2+
var Wanderlust = require('./lib/Wanderlust');
3+
var chai = require('chai');
4+
var chaiAsPromised = require("chai-as-promised");
5+
6+
chai.use(chaiAsPromised);
7+
8+
var myStepDefinitionsWrapper = function () {
9+
var seleniumAddress = 'http://localhost:4444/wd/hub';
10+
var options = { browser : 'chrome', timeout : 100000, 'desiredCapabilities': ['firefox', 'chrome'] };
11+
this.World = pc.world(seleniumAddress, options);
12+
var expect = chai.expect;
13+
14+
var wanderlust;
15+
16+
var callbackWithTimeout = function(timeout) {
17+
setTimeout(callback, timeout);
18+
};
19+
20+
this.Before(function(callback) {
21+
console.log(process.version);
22+
wanderlust = new Wanderlust(this);
23+
callback();
24+
});
25+
26+
this.After(function(callback) {
27+
//this.quit(callback);
28+
});
29+
30+
this.Given(/^I am on the Wanderlust website$/, function() {
31+
return this.browser.get("http://mywanderlust.co/");
32+
});
33+
34+
this.When(/^I search for city "([^"]*)"$/, function(destination) {
35+
return wanderlust.search(destination);
36+
});
37+
38+
this.Then(/^I should see a results dropdown$/, function() {
39+
return expect(wanderlust.hasSearchDropdown()).to.eventually.be.true;
40+
});
41+
42+
this.Then(/^I should get (\d+) results$/, function(num, callback) {
43+
utils.getElementsByClass(this, "pac-item", function(result) {
44+
result.length.should.equal(num);
45+
setTimeout(callback, 1000);
46+
})
47+
});
48+
};
49+
module.exports = myStepDefinitionsWrapper;

protractor.conf.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
exports.config = {
2+
3+
specs: [
4+
'features/*.feature'
5+
],
6+
7+
capabilities: {
8+
'browserName': 'chrome'
9+
},
10+
11+
baseUrl: 'http://localhost:8081/',
12+
13+
framework: 'cucumber',
14+
15+
cucumberOpts: {
16+
require: 'features/steps_definitions/my_steps.js'
17+
//format: 'progress'
18+
}
19+
20+
};

0 commit comments

Comments
 (0)