Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: empty strings inside shared pageobject elements cause runtime error #1377

Closed
GrayedFox opened this issue Feb 15, 2017 · 3 comments
Closed
Labels

Comments

@GrayedFox
Copy link

The error:

// error when running tests
     Error: No selector property for element "image" Instead found properties: selector,parent,name
       at Array.forEach (native)
       at Array.forEach (native)
       at Array.forEach (native)

This error happens no matter what test is run if, inside a PageObject, I do the following:

//home pageObject
const sharedElements = {
  image: '',
  header: 'h3',
  body: 'p'
}

module.exports = {
  url() { return this.api.globals.root },
  sections: {
    main: {
      selector: '.welcome-text',
      elements: {
        title: '.welcome-text__title',
        subtitle: '.welcome-text__subtitle',
        description: '.welcome-text__description'
      }
    },
    partners: {
      commands: [sharedCommands],
      selector: '.frequent-flyer-program-partnership',
      elements: {
        milesAndMore: '.frequent-flyer-program-partnership__image:nth-of-type(1)',
        asiaMiles: '.frequent-flyer-program-partnership__image:nth-of-type(2)'
      }
    },
    benefits: {
      selector: '.benefits',
      sections: {
        waitTime: {
          commands: [sharedCommands],
          selector: '.blacklane_benefits .span3:nth-child(1)',
          elements: [sharedElements]
        },
        rates: {
          commands: [sharedCommands],
          selector: '.blacklane_benefits .span3:nth-child(2)',
          elements: [sharedElements]
        },
        drivers: {
          commands: [sharedCommands],
          selector: '.blacklane_benefits .span3:nth-child(3)',
          elements: [sharedElements]
        },
        cancellation: {
          commands: [sharedCommands],
          selector: '.blacklane_benefits .span3:nth-child(4)',
          elements: [sharedElements]
        }
      }
    }
  }
}

Putting some text inside the image value solves the problem!

@GrayedFox GrayedFox changed the title Bug: empty strings cause runtime error for pageobject elements Bug: empty strings inside shared pageobject elements cause runtime error Feb 15, 2017
@beatfactor
Copy link
Member

Why would have an empty element id?

@GrayedFox
Copy link
Author

No need (in my case) for an empty string - although maybe someone else would use an empty string as a placeholder.

I just wanted to point out the runtime error - since the output was confusing ("no selector property... instead found properties selector, parent, name".

I guess updating the function that checks the selector should have some safety/defensiveness against empty strings 😸

@stale
Copy link

stale bot commented Nov 14, 2018

This issue has been automatically marked as stale because it has not had any recent activity.
If possible, please retry using the latest Nightwatch version and update the issue with any relevant details. If no further activity occurs, it will be closed. Thank you for your contribution.

@stale stale bot added the stale label Nov 14, 2018
@stale stale bot closed this as completed Nov 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants