Skip to content

Commit 3335828

Browse files
author
John Doherty
committed
Added Mammoth Workwear example test which demonstrates clicking items in hover menu and navigating to product detail page and comparing title
1 parent f344e4f commit 3335828

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

features/buy-workwear.feature

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@workwear
2+
Feature: Shop for Workwear
3+
I can search for and buy workwear
4+
5+
Scenario: View product detail
6+
Given I am on the Mammoth Workwear home page
7+
When I click navigation item "Safety Boots"
8+
And I click product item "Timberland Pro Euro Hiker 2G Safety Boots"
9+
Then I should see product detail with title "Timberland Pro Euro Hiker 2G Safety Boots"

page-objects/mammoth-workwear.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports = {
2+
3+
url: 'http://mammothworkwear.com',
4+
5+
elements: {
6+
menuItem: 'nav[role="navigation"] ul li a',
7+
productItem: 'main .pitem a'
8+
},
9+
10+
clickNavigationItem: function(containingText) {
11+
12+
return helpers.clickHiddenElement(page.mammothWorkwear.elements.menuItem, containingText);
13+
},
14+
15+
clickProductItem: function(containingText) {
16+
17+
return helpers.clickHiddenElement(page.mammothWorkwear.elements.productItem, containingText);
18+
},
19+
20+
titleContains: function(expectedTitle) {
21+
22+
return driver.getTitle(function(pageTitle) {
23+
expect(pageTitle).to.contain(expectedTitle);
24+
});
25+
}
26+
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
module.exports = function () {
2+
3+
this.Given(/^I am on the Mammoth Workwear home page$/, function (done) {
4+
5+
// load google
6+
helpers.loadPage(page.mammothWorkwear.url).then(function(){
7+
done();
8+
});
9+
});
10+
11+
this.When(/^I click navigation item "([^"]*)"$/, function (linkTitle, done) {
12+
13+
// click an item in the search results via the google page object
14+
page.mammothWorkwear.clickNavigationItem(linkTitle).then(function(){
15+
done();
16+
});
17+
});
18+
19+
this.Then(/^I click product item "([^"]*)"$/, function (productTitle, done) {
20+
21+
// click an item in the search results via the google page object
22+
page.mammothWorkwear.clickProductItem(productTitle).then(function(){
23+
done();
24+
});
25+
});
26+
27+
this.Then(/^I should see product detail with title "([^"]*)"$/, function (pageTitle, done) {
28+
29+
page.mammothWorkwear.titleContains(pageTitle).then(function(){
30+
done();
31+
});
32+
});
33+
};

0 commit comments

Comments
 (0)