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

[1.0.x] Custom commands that use execute and are called with page-object elements throw an error #1882

Closed
aberonni opened this issue Sep 13, 2018 · 1 comment

Comments

@aberonni
Copy link
Collaborator

aberonni commented Sep 13, 2018

On our codebase we make extensive use of this sort of setup:

// myPage.js
elements: {
    myElement: '#mySelector'
}

// myCustomCommand.js
exports.command = function(selector) {
    this.execute(
        function(data) {
             // execute application specific code
            return 'something';
        },
        [selector],
        function(result) {
             // do something with result
        }
    );
    return this;
};

// test
const page = browser.page.myPage()

page.myCustomCommand('@myElement')

This worked as expected with Nightwatch < 1, but with latest version it breaks, so it seems like a regression.

Nightwatch version: 1.0.11
Node version: 10.8.0
OS: MacOS 10.13.6
Selenium: 3.13.0

Error output:

   Converting circular structure to JSON
       at JSON.stringify (<anonymous>)
       at Function.jsonStringify (/Users/dom/git/nightwatch/lib/http/formatter.js:15:23)
       at HttpRequest.setOptions (/Users/dom/git/nightwatch/lib/http/request.js:69:43)
       at new HttpRequest (/Users/dom/git/nightwatch/lib/http/request.js:34:10)
       at JsonWireProtocol.createProtocolAction (/Users/dom/git/nightwatch/lib/transport/transport.js:184:21)
       at JsonWireProtocol.runProtocolAction (/Users/dom/git/nightwatch/lib/transport/jsonwire.js:49:24)
       at target.(anonymous function).definition (/Users/dom/git/nightwatch/lib/transport/actions.js:46:33)
       at Proxy.<anonymous> (/Users/dom/git/nightwatch/lib/api/protocol.js:70:18)
       at ProtocolActions.executeScriptHandler (/Users/dom/git/nightwatch/lib/api/protocol.js:1445:41)
       at ProtocolActions.execute (/Users/dom/git/nightwatch/lib/api/protocol.js:1071:21)
 Error while running .executeScript() protocol action: unknown error: 'script' must be a string

{ status: -1,
  state: '',
  value:
   { message: 'unknown error: \'script\' must be a string',
     error:
      [ '  (Session info: chrome=69.0.3497.100)',
        '  (Driver info: chromedriver=2.41.578706 (5f725d1b4f0a4acbf5259df887244095596231db),platform=Mac OS X 10.13.4 x86_64)'] },
  errorStatus: 13,
  error: 'unknown error: \'script\' must be a string',
  httpStatusCode: 200 }
No assertions ran.

You can reproduce here: https://github.com/aberonni/nightwatch-bug-report/tree/master/tests/1882

npm install
npm run test:1882
@beatfactor beatfactor added this to the Nightwatch v1.0 milestone Sep 14, 2018
@aberonni
Copy link
Collaborator Author

@beatfactor closing in favour of #1237 - could you add the v1.0 label to that issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants