maxgalbu / nightwatch-custom-commands-assertions

Nightwatch.js custom commands and assertions
MIT License
136 stars 32 forks source link

FEATURE REQUEST: Allow Sharing of Page Sections #21

Closed GrayedFox closed 7 years ago

GrayedFox commented 7 years ago

Hi there,

Using the example provided in the docs I am trying to share a nested "section" inside of some other sections, which seems to work for elements but not for sections which contain elements.

I suppose this is more of a feature request, since it isn't explicitly explained in the docs but I was hoping I could share sections the same way one shares elements.

Example:

//myPageObject.js
const sharedSections = {
  details: {
    selector: '.text-info',
    elements: {
      title: 'h2',
      ourCars: '.car-examples',
      capacity: '.capacity'
    }
  },
  priceBox: {
    selector: '.price-box',
    elements: {
      total: '.price',
      price: '.base_price',
      meetAndGreet: '.airport_fee',
      select: '.btn-continue'
    }
  }
}

const sharedElements = {
  image: '.car-image img'
}

module.exports = {
  sections: {
    carClass: {
      commands: [sharedCommands],
      selector: '[ng-controller="VehicleSelectController"]',
      sections: {
        business: {
          selector: '#vehicle-class-business',
          elements: [sharedElements],
          sections: [sharedSections]
        },
        businessVan: {
          selector: '#vehicle-class-van',
          elements: [sharedElements],
          sections: [sharedSections]
        },
        firstClass: {
          selector: '#vehicle-class-first',
          elements: [sharedElements],
          sections: [sharedSections]
        }
      }
    }
  }
}
GrayedFox commented 7 years ago

Whoops. Wrong repo. Sorry