HashNuke / hound

Elixir library for writing integration tests and browser automation

Home Page:http://hexdocs.pm/hound

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

anonymous functions in execute_script

mguilmineau opened this issue · comments

Greetings, just so you know I was running (in chromium's latest) execute_script with an anonymous function in it that referenced arguments, as such:
execute_script( "const e=arguments[0], i=(function(s){ val = arguments[1] ; ... })(e) ; ...", [ arg0, arg1] )
Turns out that while e is properly defined as taking the value of arg0, once inside the anonymous function arguments is equals to [e] i.e. what was passed to the anonymous function, not [ arg0, arg1] any longer.
That's an unfortunate side-effect of having named your arguments "arguments" I suppose. :)
My workaround was to define an extra variable taking arg1 as its value, before the anonymous function then invoke that variable from within. But ideally there's no having to worry about that array's value being overwritten at execution time.