refactor app directory structure and add tests
This commit is contained in:
17
tests/node_modules/nightwatch/examples/pages/home.js
generated
vendored
Normal file
17
tests/node_modules/nightwatch/examples/pages/home.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
var searchCommands = {
|
||||
submit: function() {
|
||||
this.waitForElementVisible('@submitButton', 3000)
|
||||
.click('@submitButton')
|
||||
.api.pause(1000);
|
||||
return this; // Return page object for chaining
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
url: 'http://google.com',
|
||||
commands: [searchCommands],
|
||||
elements: {
|
||||
searchBar: { selector: 'input[name=q]' },
|
||||
submitButton: { selector: '[type=submit]' }
|
||||
}
|
||||
};
|
31
tests/node_modules/nightwatch/examples/pages/searchResults.js
generated
vendored
Normal file
31
tests/node_modules/nightwatch/examples/pages/searchResults.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
var util = require('util');
|
||||
|
||||
var menuXpath = '//div[contains(@class, "hdtb-mitem")][contains(., %s)]';
|
||||
|
||||
var menuCommands = {
|
||||
productIsSelected: function(product, callback) {
|
||||
var self = this;
|
||||
return this.getAttribute(product, 'class', function(result) {
|
||||
var isSelected = result.value.indexOf('hdtb-msel') > -1;
|
||||
callback.call(self, isSelected);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
elements: {
|
||||
results: { selector: '#ires' }
|
||||
},
|
||||
sections: {
|
||||
menu: {
|
||||
selector: '#hdtb-msb',
|
||||
commands: [menuCommands],
|
||||
elements: {
|
||||
web: { selector: util.format(menuXpath, 'Web'), locateStrategy: 'xpath' },
|
||||
video: { selector: util.format(menuXpath, 'Video'), locateStrategy: 'xpath' },
|
||||
images: { selector: util.format(menuXpath, 'Images'), locateStrategy: 'xpath' },
|
||||
shopping: { selector: util.format(menuXpath, 'Shopping'), locateStrategy: 'xpath' }
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user