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.82k stars 1.32k forks source link

Pageobjects overwrite parameter of custom command #787

Closed maxgalbu closed 5 years ago

maxgalbu commented 8 years ago

Hi, I'm trying to use this custom command:

https://github.com/maxgalbu/nightwatch-custom-commands-assertions/blob/0ad46de1009bafdfbe7154a5c54f8932f3dc87cf/js/commands/waitForText.js

When i call it without page objects it works: (see here: https://github.com/maxgalbu/nightwatch-custom-commands-assertions/blob/0ad46de1009bafdfbe7154a5c54f8932f3dc87cf/tests/runTests.js#L109-L118)

But when I call it with a page object, the second parameter of the command is not the variable I'm expecting, but this nightwatch function:

function () {
            parent.client.locateStrategy = prevLocateStrategy;
            if (callback) {
              callback.apply(parent.client, arguments);
            }
          }

This is an example:

var pageObject = browser.page.test();
browser.url("http://localhost/waitForText");
    pageObject.waitForText("@textWaitCss", function (text) {
        return text === "something else";
    });

This is the page object:

module.exports = {
    elements: {
        textWaitCss: {
            selector: '#div',
            locateStrategy: "css",
        }
    },
}
nekoyama commented 6 years ago

OMG!!! @maxgalbu I think that the jqueryClick custom command is not working as well when using a page object.

I am trying to do the following:

pageObject:
command(externalLinkText){ 
client.jqueryClick("'(@externalLink):contains(externalLinkText)')");
}
@externalLink: 'a[href^="http"]'

console:
$('a[href^="http"]:contains(text)')

@beatfactor which "more info" is required here?
👎 👎 Too bad that this is open for 3 years now. >_< .

stale[bot] commented 5 years ago

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 contributions.

maxgalbu commented 5 years ago

@nekoyama I think this was fixed in https://github.com/nightwatchjs/nightwatch/commit/e7416d3ca96de62a6b6aee368da32e7e2c04d5a9 so I'll close this. Please let me know if you think this is a bug in nightwatch or my custom commands