Darrell DeBoer wrote:
I'm not sure what you mean. ...
Maybe I'm missing something, though?
I didn't really explain it very well.
Let's use the locators functions as an example. I'm figuring that they
still get invoked in an OO-way, with "this" referring to a pageBot
instance. Currently we call locator functions as:
var locatorFunction = pageBot.locationStrategies[locatorType];
return locatorFunction.call(pageBot, locator, inDocument);
Because we're explicitly providing a (pageBot) receiver in the call, it
doesn't actually matter whether the locator functions are declared as
properties of a PageBot object, or elsewhere. Let's say you had a
global, static locator registry in "Selenium.locators". You could do
something like
Selenium.locators['xpath'] = function(xpath, document) {
// "this" is a PageBot
// ... etc ...
};
and the locator invocation changes to
var locatorFunction = Selenium.locators[locatorType];
return locatorFunction.call(pageBot, locator, inDocument);
Any clearer?
If you wanted to vary locator behaviour per browser-type, the locator
function could delegate to a overridable function:
Selenium.locators['id'] = function(id, document) {
return this.locateElementByIdentifier(id, document);
};
What does this buy us? Well, I'm just looking to define an "extension
API" where people can plug in their own locators, etc, but that allows
us to modify the internals down the track. But I'm not sure whether the
locator registry should hang off "Selenium", or "BrowserBot", or
"BrowserBot.prototype".
It falls down if we ever want to make a locator available for one
browser-type but not others. But, would that ever be a useful thing to do?
--
cheers, MikeW http://www.dogbiscuit.org/mdub/
_______________________________________________
Selenium-devel mailing list
Selenium-devel@lists.public.thoughtworks.org
http://lists.public.thoughtworks.org/mailman/listinfo/selenium-devel