java -jar selenium-server.jar -userExtensions user-extensions.js -browserSideLog -singleWindow
The error you're describing doesn't sound like a problem with your user extensions.js being unavailable. You'll have to be a little more forthcoming if you want a hand.
Ross
I'm obviously not in a position to try your test myself, but I would expect it to work, at least up to this point:
> sel.ScrollDown("terms-of-use")
At that point, I wouldn't be surprised if Python gave you an error message telling you that "ScrollDown" doesn't exist. Unless you've done something to define your new command to the Python "selenium" object, there's no way for it to know that it exists. If you take a look at selenium.py in the Selenium Python package, you'll see that almost all the commands are defined very simply as either "self.do_command('...commandname...', [...arguments...])" or "return self.get_...datatype...('...commandname...', [...arguments...])", depending on whether they are "actions" or "accessors" respectively.
You have several options for using your new Selenium command. The cleanest is probably to create your own subclass of "selenium" and implement the command yourself. My Python doesn't get a lot of exercise, but I'd expect something like this would do the job:
class mySelenium(selenium):
def __init__(self, host, port, browserStartCommand, browserURL):
super(mySelenium, self).__init__(host, port, browserStartCommand, browserURL)
def ScrollDown(self, locator):
self.do_command("scrollDown", [locator, ])
Note that the command you send to Selenium RC is "scrollDown", not "ScrollDown". And then to use it:
class UREG(unittest.TestCase):
def setUp(self):
self.verificationErrors = []
self.selenium = mySelenium("localhost", 4444, "*firefox", config.testEnv)
self.selenium.start()
def test_UREG(self):
sel = self.selenium
...
sel.click("edit-confirm-community-terms-of-use")
sel.ScrollDown("terms-of-use")
...
Ross
These all sound like issues a Python programmer ought to be able to solve. I rarely use Python myself, but I know enough to be able to play around with it and answer questions like yours yesterday. Until you get the subclass of "selenium" to be usable by your test script, you'll of course have no luck with Selenium RC and your command. Sorry, but I can't be of any help with this.
>On another note, I was under the assumption that I did not need to
>declare this command in selenium.py since I have wrote the code
>(javascript) in user-extensions.js. Shouldn't RC be able to read the
>command from there?
Nope. Most of the Selenium RC client packages, including the Python client, are built by scanning the Selenium Core "selenium-api.js" file and creating callable wrappers for all the commands that are found. Your command isn't there, so no wrapper was created. And you probably didn't build the Selenium RC Python client yourself, so even if you had put your extension into selenium-api.js, there still wouldn't have been a wrapper because, well, it wasn't there when it was built.
>I have also seen the preferred method of using HTTPCommandProcessor in
>the selenium tutorial but the code is written only in C#. I am not
>sure if this would apply to python nor how to convert it from C# to
>python.
The Python equivalent of the Selenium RC C# client's HTTPCommandProcessor module is so lightweight that it almost doesn't exist. The C# suggestion of 'string[] inputParams = {"Hello World"}; proc.DoCommand("alertWrapper", inputParams);' is essentially the same as the body of what I suggested for your "scrollDown()" method, so I expect this would work: 'sel.do_command("scrollDown", [locator, ])'
Ross
-adam
The Python bindings are convenience wrappers around calls into the Se-RC
server. They are completely disconnected. You will have to define the
scrolldown method yourself and import it into your tests in order to
have it executed on the server. Something like this should do the trick.
def scroll_down(self, locator):
self.do_command("scrollDown", locator)
That function provides the bridge from Python to the Server which knows
about your custom bit of JS.
-adam