开发者

Selenium-Grid: How to use `user-extensions.js`

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 k开发者_StackOverflow社区now how to do this? Thanks.


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. :)


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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜