Skip to content

Conversation

@aaltat
Copy link
Contributor

@aaltat aaltat commented Aug 16, 2018

No description provided.

@aaltat aaltat force-pushed the js_approval_tests branch from 918b48e to eae867d Compare August 27, 2018 20:14
@aaltat
Copy link
Contributor Author

aaltat commented Aug 27, 2018

Fixes #323

@aaltat
Copy link
Contributor Author

aaltat commented Aug 27, 2018

Need to take a look on few things:

  1. Are error messages good.
  2. Can _separate_code_and_args simplified. Now it has quite many moving parts.
  3. Proof read the new keyword docs. The error message says marker but doc says statement

Copy link
Member

@pekkaklarck pekkaklarck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Some nitpickey line notes added. I'll review the code related to finding JS code and arguments when I got time.

return self.driver.execute_script(js)
js_code, js_args = self._get_javascript_to_execute(code)
self.info('Executing JavaScript:\n%s\nBy using argument(s):\n"%s"'
% (js_code, ', '.join(js_args)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logging could be enhanced a little:

  • Better not to mention anything about arguments if there are none. Current "" looks odd.
  • Instead of "argument(s):" it's possible to use "argument%s:" % robot.utils.plural_or_not(js_args) to get the trailing s when needed.
  • Quotes around arguments like "first, second" look a bit strange. I'd consider omitting them altogether or alternatively quoting each argument separately. In the latter case robot.utils.seq2str or seq2str2 might be worth a look. Just logging js_args as-is would be fine otherwise as well, but the u prefixes with Unicode strings inside a list in Python 2 are annoying.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not know that such utils did exist. I definitely will take a look.

return code
js_code, js_args = self._get_javascript_to_execute(code)
self.info('Executing Asynchronous JavaScript:\n%s\nBy using argument(s):\n"%s"'
% (js_code, ', '.join(js_args)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about logging as above. Logging should probably be done using a helper.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Helper is good idea. Will definitely take a look.

js_code.append(line)
if get_args:
js_args.append(line)
return js_code, js_args
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks a bit complicated. Don't have time to look at more closely could it be improved. Will look again later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's complicated. At least raising an error could be moved to a separate method. Need to think what else could be done.

@aaltat aaltat merged commit 8edce40 into robotframework:master Sep 10, 2018
@aaltat aaltat deleted the js_approval_tests branch September 13, 2018 20:05
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

Successfully merging this pull request may close these issues.

2 participants