Selenium RC Per-Session Extension Javascript

Several people have asked if it is possible to specify user extension Javascript dynamically with the RC, as opposed to on the command line with the -userExtensions flag when starting up the server. It wasn’t possible before.

It should be now.

If you build from r2291 or greater from the RC trunk, you can play with it. Basically, the extension Javascript must be specified before the browser is launched, and stays in-play until the session is closed. A sample test has been checked in here:

SessionExtensionJsTest.java

This probably doesn’t work for proxy injection mode yet.

Happy extending! :)

Update

It appears too easy to encounter the “414 Request URI Too Large” issue. I’m looking into this.

Update

Looks like the 414 issue is related specifically to the Perl driver (see this Clearspace post); I noticed it when using Perl, but did not see the issue when running an equivalent test in Groovy:

import com.thoughtworks.selenium.*

class URILengthTest extends GroovyTestCase {
    def selenium

    @Override
    void setUp() {
        selenium = new DefaultSelenium('localhost',
            4444, '*firefox',
            'http://alistapart.com')
    }

    @Override
    void tearDown() {
        selenium.stop()
    }

    void testURILength() {
        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')
    }
}

Update

Unfortunately, the 414 issue also affects the Python and Ruby client drivers (I just tested and verified this). I’m not about to fix them right this moment, so it appears the you can only truly take advantage of the per-session extension feature (i.e. include extensions of arbitrary size) in Java and Groovy for now. :( The good news is that this issue has already been reported, and JIRA tickets created (SRC-319 for Perl, SRC-321 for Python, SRC-322 for Ruby, and others for C# and PHP).

Leave a Reply


Bad Behavior has blocked 265 access attempts in the last 7 days.