Skip to content

Commit

Permalink
Fix google page-object and the example using it. (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
uditrajput03 authored Mar 11, 2024
1 parent ad0350a commit 39ee877
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ describe('google search with consent form - page objects', function() {
resultsPage.expect.section('@menu').to.be.visible;

const menuSection = resultsPage.section.menu;
menuSection.expect.element('@all').to.be.visible;
menuSection.expect.element('@videos').to.be.visible;
});
});
13 changes: 8 additions & 5 deletions assets/js-examples-new/page-objects/google/searchResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
*/

const util = require('util');
const menuXpath = '//div[contains(@class, "hdtb-mitem")][contains(., "%s")]';

// starting xpath with './/' tells browser to begin search from the current element,
// while starting with '//' tells browser to begin search from the start of html document.
const menuXpath = './/span[contains(text(), "%s")]';

const menuCommands = {
productIsSelected: function(product, callback) {
Expand All @@ -33,15 +36,15 @@ module.exports = {

sections: {
menu: {
selector: '#hdtb-msb',
selector: 'div[role="navigation"] div[data-st-cnt="mode"]',
commands: [menuCommands],
elements: {
all: {
selector: util.format(menuXpath, 'All'),
maps: {
selector: util.format(menuXpath, 'Maps'),
locateStrategy: 'xpath',
index: 0
},
video: {
videos: {
selector: util.format(menuXpath, 'Videos'),
locateStrategy: 'xpath',
index: 0
Expand Down

0 comments on commit 39ee877

Please sign in to comment.