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

AppDriver$wait_for_js() does not quote script input #236

Closed
fproske opened this issue Jul 21, 2022 · 4 comments · Fixed by #258
Closed

AppDriver$wait_for_js() does not quote script input #236

fproske opened this issue Jul 21, 2022 · 4 comments · Fixed by #258
Labels
bug Something isn't working
Milestone

Comments

@fproske
Copy link

fproske commented Jul 21, 2022

The eval() call in the chromote_wait_for_condition function is essentially a NOP instruction as the condition_js script is not quoted:

return eval(", condition_js, ");

This leads to e.g. the input script 'test'==='test'; throwing a Javascript error: SyntaxError: Unexpected token ';'. Expected ')' to end an argument list. as the code to be executed looks like this: eval('test'==='test';) which is obviously invalid syntax.
To fix this, the condition_js needs to be quoted properly.

@schloerke schloerke added the bug Something isn't working label Aug 18, 2022
@schloerke schloerke added this to the v0.2.0 milestone Aug 18, 2022
@yogat3ch
Copy link

Hi @schloerke,
opening this back up because I found a bug where an object of class glue, character passed as the condition_js argument to wait_for_js will produce an error.

app$wait_for_js(UU::glue_js("$('#*{ns('highlighted')}* table.dataTable > tbody > tr').length == 1;"))

produces an error:
image

I think this can be resolved by simply wrapping condition_js on the line mentioned above in as.character as the following works:

app$wait_for_js(as.character(UU::glue_js("$('#*{ns('highlighted')}* table.dataTable > tbody > tr').length == 1;")))

@schloerke
Copy link
Collaborator

{glue} is so weird. lol.

Thank you for the fix!

@schloerke
Copy link
Collaborator

@yogat3ch Hopefully fixed in #288

@yogat3ch
Copy link

@schloerke Very much appreciated!!! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants