Selecting section elements in Nightwatch

时间:2019-03-05 16:41:25

标签: javascript automated-tests functional-testing nightwatch.js pageobjects

I just started using Nightwatch and I'm encountering an issue when I try to select section elements (Nightwatch - Defining Secitons). I was under the impression that when you define a selector for a section, all of the elements in that section would be children of that selector. From the docs - "Provide element-level nesting so that any element defined within a section is a descendant of its parent section in the DOM."

This is the example section given in the Nightwatch docs:

module.exports = {
  sections: {
    menu: {
      selector: '#gb',
      elements: {
        mail: {
          selector: 'a[href="mail"]'
        },
        images: {
          selector: 'a[href="imghp"]'
        }
      }
    }
  }
};

I thought that if I use the @mail selector, behind the scenes it would actually look for the following element #gb a[href="mail"]. It looks like from my testing however, that using the @mail selector just looks for a[href="mail"]. Is this the intended behavior or am I doing something wrong? Is there a specific way to reference this element so that it will properly 'inherit' the section selector?

If I'm mistaken about the behavior section selection, than what is the purpose of the sections selector property?

Thanks!

0 个答案:

没有答案