title: How to test jquery ajax tabs with selenium?
body: <p>I'm testing a django app with selenium, and one of my pages uses the <a href="http://jqueryui.com/demos/tabs/#ajax" rel="nofollow noreferrer">jquery ui tabs element</a>. 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 <em>click</em> 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 <em>still</em> not working!<br/><br/>
      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:</p>
  
  <pre><code>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)
  </code></pre>