Nightwatch: Documentation and return value for getAttribute don't match

Created on 17 Dec 2014  Â·  7Comments  Â·  Source: nightwatchjs/nightwatch

Regarding the docs on command: http://nightwatchjs.org/api#getAttribute

I just tested and this function actually returns a reference to the client object, rather than the attribute itself; presumably this is for chaining.

In my personal opinion, I feel like it would would better to return the attribute itself, since there is no way to pass data into the callback, hence you pretty limited with what you can do with the command as it is. Or you could allow data to be passed to the callback as an argument.

screen shot 2014-12-17 at 2 00 02 pm

invalid

Most helpful comment

Okay, maybe you could just update the documentation?

All 7 comments

I agree with francisbyrne.

Could you make getAttribute return the value of the specified attribute?

For my tests to be useful I want to assign the value of the attribute (ie result.value) to a variable.

This doesn't seem to be possible at the moment.

What I want to do is get the values of some attributes on one webpage and assert that the same attribute values appear on a 2nd webpage.

Can you suggest a workaround for this in the meantime?

Thanks

I'm afraid that's not possible.

Okay, maybe you could just update the documentation?

http://nightwatchjs.org/api/#getAttribute — The documentation is still incorrect

As of this writing, documentation remains incorrect. Can anyone provide me with a code example that properly returns the attribute value? When I call .value on the result in the callback, console output simply shows [object Object]

Try wrapping it in JSON.stringify(result.value) before passing it to console.log, this will properly format the object as a string and get you further with your debugging :)

As of this writing, the documentation still remains outdated.

The result is an object and to query the return value you should reference to result.value.

Was this page helpful?
0 / 5 - 0 ratings