searchResults.js 931 B

12345678910111213141516171819202122232425262728293031
  1. var util = require('util');
  2. var menuXpath = '//div[contains(@class, "hdtb-mitem")][contains(., %s)]';
  3. var menuCommands = {
  4. productIsSelected: function(product, callback) {
  5. var self = this;
  6. return this.getAttribute(product, 'class', function(result) {
  7. var isSelected = result.value.indexOf('hdtb-msel') > -1;
  8. callback.call(self, isSelected);
  9. });
  10. }
  11. };
  12. module.exports = {
  13. elements: {
  14. results: { selector: '#ires' }
  15. },
  16. sections: {
  17. menu: {
  18. selector: '#hdtb-msb',
  19. commands: [menuCommands],
  20. elements: {
  21. web: { selector: util.format(menuXpath, 'Web'), locateStrategy: 'xpath' },
  22. video: { selector: util.format(menuXpath, 'Video'), locateStrategy: 'xpath' },
  23. images: { selector: util.format(menuXpath, 'Images'), locateStrategy: 'xpath' },
  24. shopping: { selector: util.format(menuXpath, 'Shopping'), locateStrategy: 'xpath' }
  25. }
  26. }
  27. }
  28. };