nightwatchjs / nightwatch

Integrated end-to-end testing framework written in Node.js and using W3C Webdriver API. Developed at @browserstack
https://nightwatchjs.org
MIT License
11.84k stars 1.33k forks source link

ad-hoc section feature request #3958

Open ldziadkowiec opened 11 months ago

ldziadkowiec commented 11 months ago

Description

When dealing with UI generated dynamically we struggle to define a proper page objects for it. Sometimes it is useful to create an ad-hoc section and to call commands on it. Right now we have to fabricate whole xpath from the root of the page object to that element and have special command to run on them instead of having generic ones.

Suggested solution

    currencies: {
      selector: getSettingsSectionSelector('Currencies'),
      locateStrategy: 'xpath',
      commands: [{
        waitForVisible() {
          return this.waitForElementVisible(this, 'Section Currencies visible...');
        },
        expectSelectedTargetRowEquals(title) {
          const selector = getMyUIElementSelectorByTitle(title);
          const locateStrategy = 'xpath;

          this
            .getNewSection(selector, locateStrategy)
            .myCommand(data)
        },

Alternatives / Workarounds

No response

Additional Information

No response

github-actions[bot] commented 11 months ago

Thank you for setting this as an enhancement. One of the product folk will triage this again to help see when we can fit this in an upcoming sprint.

beatfactor commented 11 months ago

Can you describe a bit more your setup/environment? I think I understand the issue, but I'm not really sure I follow the workaround you're using. Perhaps you can give an example of how this could be used in a test?