Closed spooning closed 9 years ago
Originally submitted to Google Code by @yanne on 8 Feb 2010
Actually, the do_command does not do the trick, since some methods in the API do not use do_command directly.
I implemented this based on getattr, implementation is in r300. Should be reviewed. Also, would Call Selenium Method or Call Selenium Function work better as keyword name?
Originally submitted to Google Code by @pekkaklarck on 9 Feb 2010
1) Perhaps this could be implemented so that the keyword first tries to find a
matching method from the Python API using getattr
and, if that fails, uses
do_command
. Something like this:
try: method = getattr(self._selenium, method_name) except AttributeError: method = lambda _args: self._selenium.do_command(method_name, args) method(_args)
2) The current implementation catches TypeError assuming it's caused by calling the method with invalid arguments. The problem is that this potentially masks other TypeErrors and reports them incorrectly to the user. In my opinion it's better to just call the method and let it blow up if it's called incorrectly -- this is anyway a very low-level keyword and users should know what they do.
3) For some reason I like Call Selenium API
more than Call Selenium Method
or
Call Selenium Function
. Perhaps Call Selenium RC
or Call Selenium Remote Controller
would be OK too.
Originally submitted to Google Code by @yanne on 10 Feb 2010
I revised the implementation in r335 and r336.
Do we need to document the differences in calling a remote control method with underscore_name and calling do_command with camelCase name? The former returns always formatted result whereas the latter returns raw result in the form 'STATUS,response'
Originally submitted to Google Code by @pekkaklarck on 11 Feb 2010
I think the different "call modes" needs to be documented but not on very low level. Perhaps something like this:
"""The keyword first tries to find a method in Selenium's Python API provided by the
selenium.py
file. If no matching method is found, the keyword calls the Selenium
Server's Remote Controller API directly via the do_command
method in the Python
API. In both cases the keyword returns the return value of the call directly without
any modifications or verifications.
Examples: ..."""
Originally submitted to Google Code by @yanne on 11 Feb 2010
Updated doc in r351
The Selenium API still has a lot of functionality we don't yet expose in the SeleniumLibrary. It would be nice to have a keyword that allowed calling any method in the Selenium API directly so that all this functionality would be available. Probably something like below could do the trick:
def call_selenium_api(self, method, *args): """Calls a method in the Selenium remote controller API directly.