Skip to content

Commit ff4a719

Browse files
author
John Doherty
committed
updated all examples to use promises (done is a bad idea)
1 parent fd77164 commit ff4a719

File tree

2 files changed

+21
-31
lines changed

2 files changed

+21
-31
lines changed
Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,25 @@
11
module.exports = function () {
22

3-
this.Given(/^I am on the Mammoth Workwear home page$/, function (done) {
3+
this.Given(/^I am on the Mammoth Workwear home page$/, function () {
44

55
// load google
6-
helpers.loadPage(page.mammothWorkwear.url).then(function(){
7-
done();
8-
});
6+
return helpers.loadPage(page.mammothWorkwear.url);
97
});
108

11-
this.When(/^I click navigation item "([^"]*)"$/, function (linkTitle, done) {
9+
this.When(/^I click navigation item "([^"]*)"$/, function (linkTitle) {
1210

1311
// click an item in the search results via the google page object
14-
page.mammothWorkwear.clickNavigationItem(linkTitle).then(function(){
15-
done();
16-
});
12+
return page.mammothWorkwear.clickNavigationItem(linkTitle);
1713
});
1814

19-
this.Then(/^I click product item "([^"]*)"$/, function (productTitle, done) {
15+
this.Then(/^I click product item "([^"]*)"$/, function (productTitle) {
2016

2117
// click an item in the search results via the google page object
22-
page.mammothWorkwear.clickProductItem(productTitle).then(function(){
23-
done();
24-
});
18+
return page.mammothWorkwear.clickProductItem(productTitle);
2519
});
2620

27-
this.Then(/^I should see product detail with title "([^"]*)"$/, function (pageTitle, done) {
21+
this.Then(/^I should see product detail with title "([^"]*)"$/, function (pageTitle) {
2822

29-
page.mammothWorkwear.titleContains(pageTitle).then(function(){
30-
done();
31-
});
23+
return page.mammothWorkwear.titleContains(pageTitle);
3224
});
3325
};
Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
module.exports = function () {
22

3-
this.When(/^I search Google for "([^"]*)"$/, function (searchQuery, done) {
3+
this.When(/^I search Google for "([^"]*)"$/, function (searchQuery) {
44

5-
driver.get('http://www.google.com');
6-
7-
var input = driver.findElement(by.name('q'));
8-
9-
input.sendKeys(searchQuery);
10-
input.sendKeys(selenium.Key.ENTER);
11-
12-
done();
5+
return driver.get('http://www.google.com').then(function(){
6+
return driver.findElement(by.name('q'));
7+
})
8+
.then(function(el){
9+
return el.sendKeys(searchQuery + selenium.Key.ENTER);
10+
});
1311
});
1412

15-
this.Then(/^I should see some results$/, function (done) {
13+
this.Then(/^I should see some results$/, function () {
1614

17-
driver.wait(until.elementsLocated(by.css('div.g')), 10000);
18-
19-
driver.findElements(by.css('div.g')).then(function (elements) {
15+
return driver.wait(until.elementsLocated(by.css('div.g')), 10000).then(function(){
16+
return driver.findElements(by.css('div.g'));
17+
})
18+
.then(function (elements) {
2019
expect(elements.length).to.not.equal(0);
21-
done();
22-
});
20+
});
2321
});
2422
};

0 commit comments

Comments
 (0)