Hello world!
I'm testing a django app with selenium, and one of my pages uses the jquery ui tabs element. One of the tabs contains a simple table listing some users, and is loaded via ajax. When using the app, the tab works just fine, but when automating the test with selenium, the tab doesn't appear to load it's content!
I'm writing the tests myself in python. At first, I was using the click method of selenium RC, but as I -painfully- learned from a previous test, that is rather buggy when it comes to anchor tags, so I resorted to the solution I used before: the wait_for_condition method and explicitly called the tab click event (and even the load event!) and nevertheless the tab was still not working!
I'm in despair here, the majority of my tests depend on that page and almost half of them are on that table, but, alas, it seems selenium is screwing up the javascript!
(I have other tests in the class, and they run just fine, so nothing weird is going on at the server level, it seems to be a problem caused by selenium in the client side)
My test code is similar to this:
class TestMyApp(TransactionTestCase):
urls = 'myapp.test_urls'
def setUp(self):
self.verificationErrors = []
self.selenium = selenium("localhost", 4444, "*chrome", "http://localhost:8000/")
self.selenium.start()
#self.selenium.set_speed(2000)
self.selenium.window_maximize()
def test_users_list(self):
"""Test that an app's users are correctly listed"""
sel = self.selenium
users = []
for u in range(settings.FREE_USER_LIMIT/2):
users.append(self.app.users.create(name="testUser_%s"%uuid4()))
sel.open("/")
sel.wait_for_page_to_load("30000")
sel.wait_for_condition('selenium.browserbot.getCurrentWindow().jQuery("#tabs").tabs("select",1);\
selenium.browserbot.getCurrentWindow().jQuery("#tabs").tabs("load",1);',
3000)
for user in users:
try: self.failUnless(sel.is_text_present(user.name))
except AssertionError, e: self.verificationErrors.append(str(e))
try: self.failUnless(sel.is_text_present(str(user.added.date())))
except AssertionError, e: self.verificationErrors.append(str(e))
def tearDown(self):
self.selenium.stop()
self.assertEqual([], self.verificationErrors)