Cannot execute custom Selenium assert function from user-extensions.js file, when running Python RC


I'm trying to export a Selenium script to Python from the Selenium IDE. I am using a few user-extension.js functions though (which are working in Selenium IDE). After exporting to Python, the generated script looks like this:

from selenium import selenium import unittest, time, re class new_selenium_test(unittest.TestCase): def setUp(self): self.verificationErrors = [] self.selenium = selenium("localhost", 4444, "*chrome", "http://localhost/") self.selenium.start() def test_selenium_assert_something(self): sel = self.selenium # sel.assert_something("abc=1", "x=126") def tearDown(self): self.selenium.stop() self.assertEqual([], self.verificationErrors) if __name__ == "__main__": unittest.main()

Note that the most interesting line, where I call my user extension code (function "assert_something", which maps on function "assertSomething" in my user-extensions.js file), is commented out. When I activate that line and run the script against Selenium server like this:

py.test new-selenium-test.py

I get an error like this:

AttributeError: 'selenium' object has no attribute 'assert_something'

Any idea why Selenium IDE comments out my custom call, and why it does not execute it from Python?

Note that I have started the Selenium server like this:

java -jar selenium-server-standalone-2.0rc2.jar -userExtensions /path/user-extensions.js

Thanks for your help!


You need to rewrite your custom JavaScript functions in Python, as described here:

<a href="http://groups.google.com/group/selenium-users/browse_thread/thread/e927dad7e6cb2944/1712b997934cece5" rel="nofollow">http://groups.google.com/group/selenium-users/browse_thread/thread/e927dad7e6cb2944/1712b997934cece5</a>

It can't connect the Python object to your custom JS, so it leaves that comment there to remind you to implement it in Python.


  • Eclipse Outline View - Visible JavaScript Categories in Eclipse?
  • Opening Selenium Webdriver tests in the same window
  • Compile-errors: “creating array with negative size ('-0x00000000000000001')”, “assignment
  • How to determine which eclipse dependencies to use
  • performSelector in NSOperation subclass
  • JavaScript get page coordinates of closest clicked character
  • select only 1st level of nested elements
  • How do I interpolate a line number from __LINE__ into the name of a test in Perl?
  • Only first logging shows unless forcefully disposing
  • How to communicate between ASPX and WinForms
  • Protocol issue connecting Derby by db2 ODBC
  • Django: ImportError: No module named quiz.views
  • How to make Firefox handle the result of a POST request with firefox-addon-sdk?
  • Submitting form to couchDB through update handler not working
  • Why does _GET in PHP wrongly decodes slash?
  • No error while instantiating abstract class, even though abstract method is not implemented
  • MongoError: getaddrinfo ENOTFOUND undefined undefined:27017
  • How do I get the post request with express js?
  • Htaccess 301 redirect htaccess or php
  • Cannot send user message with Spring Websocket
  • Geo Fix not working in Android SDK 2.2
  • Rails Route parameters in AngularJS
  • how to post with curl to REST/JSON service?
  • Why does the first run of “XCTestCase -measureBlock:” takes so much time?
  • Get highlight text in current window and send it in a popup
  • How to use Servicestack PostFileWithRequest
  • Rails 2 Mailer View Prepending 3D to strings
  • How to configure a timeout for an SQL query in Groovy?
  • How to run a set of SQL queries from a file, in PHP?
  • Using extern @class in order to add a category?
  • Replace and retrieve placeholder value
  • How to map Request parameter in Spring?
  • Getting error java.io.FileNotFoundException (log4j log file) at the time of publish project on cloud
  • JSON - slashes not escaping
  • SF2 Functional tests : “Resetting the container is not allowed when a scope is active”
  • CORS with socket.io
  • mave 3.2 not able to access local nexus instance return 502 code
  • Setting the run time properties on SpringApplicationBuilder()
  • Tomcat memory Leak
  • Cannot resolve symbol 'MyApi'