views:

314

answers:

2

We're converting our Selenium tests to use Selenium-Grid.

I'm trying to find a way to launch selenium-grid's hub and/or remote so that it can use the user-extensions.js that we created before. I've been able to get everything to work with our old tests except for our extensions.

Searching online I found that you can edit the project.properties file in the selenium-grid root directory and add the user_extension_file property to point to the user-extensions.js.

user_extension_file=${basedir}/user-extensions.js

I've also tried using a relative and an absolute path for the value of that property, and none of them work. I've tried adding that to both the Hub's root selenium-grid folder and the RC's root selenium-grid folder.

Does anyone know how to do this? Thanks.

+1  A: 

Have you tried using setExtensionJs ?

Basically, the extension Javascript must be specified before the browser is launched, and stays in-play until the session is closed.

selenium = new DefaultSelenium('localhost', 4444, '*firefox', 'http://alistapart.com');
def extensionJs = new File('selenium-core/src/main/resources/core/scripts/ui-map-sample.js').text;
selenium.setExtensionJs(extensionJs);
selenium.start();
selenium.open('http://alistapart.com');
selenium.click('ui=allPages::section(section=topics)');
selenium.waitForPageToLoad('5000');
selenium.stop();

From: http://ttwhy.org/home/blog/2008/05/14/selenium-rc-per-session-extension-javascript/

Dave Hunt
The last comment on that blog states: "Just a heads-up for anyone trying to use this SetExtensionJS() interface. You can’t use this to create a Selenium command like you can with user-extensions.js, because the code that registers command handlers is run before SetExtensionJS() injects your code." which is what I'm trying to. I attempted this approach anyway and it didn't work.
Joel
@Joel: Yeah, that comment was mine. The whole selenium-api.js command handler thing really limits what you can do with user-extensions.js
Ross Patterson
+2  A: 

Ok, I figured this out (finally). When you launch the Remote Control using the ant task, you can do this:

ant launch-remote-control -DseleniumArgs="-userExtensions path/to/user-extensions.js" ...

That worked like a charm. :)

Joel