My understanding is that all Selenium RC drivers have a one to one relationship between command methods and RPC calls to the browser. In other words, this code will make five synchronous sequential remote calls.
rc.click(here)
rc.click(there)
rc.click(here)
rc.getEvale(js)
rc.click(there)
This could be optimized to make two remote calls (it cannot be optimized to one command because the forth method invocation has a return value).
Rough idea as to how to implement this :
Use a Proxy Design Pattern to intercept all RC method calls and push each to an internal queue. If the command can be batched, do nothing unless this is the last command in the test. If the command cannot be batched, flush the queue.
From Huggins in a private conversation :
>It's a good idea.. The XML-RPC protocol has a notion of "boxcarring" requests in a similar way using a "multiCall" command... No reason we >couldn't/shouldn't do the same in Selenium... I suggest opening an Jira ticket for it, with a description of how it could/should work, then fire off a note >to the selenium dev list for more opinions.
>Here's an example of the "multiCall" API in Python for xml-rpc:
>
http://docs.python.org/lib/node656.html
Challenges that I see:
How do you know when the last command is? I would not be a big fan of this :
rc.startTransaction()
rc.click(there)
rc.click(that)
rc.commitTransaction() // flushes the queue