The execute_script and execute_async_script methods already accept most primitives (string, integer, array, nil). It would fully complete the set if we could pass hashes directly to selenium as arguments. I'm assuming they would be serialized to JSON by the selenium bridge, and then parsed on the JS side before being passed into the script as arguments.
With Ruby's built-in support for JSON serialization, it would be even better if selenium just serialized any unknown object to JSON (duck-typing on #to_json) and then parsing on the JS side.
hash example:
driver.execute_async_script("foo.apply(null, arguments)", {a: 1})
or via duck-typing
class Foo
def to_json
...
end
end
driver.execute_async_script("foo.apply(null, arguments)", Foo.new)