def ajax_wait_for_element(element_id, seconds, status='show', check_interval = $testwise_polling_interval)
      count = 0
      check_interval = 1 if check_interval < 1 or check_interval > seconds
      while count < (seconds / check_interval) do
        search_indicator = @web_browser.element_by_id(element_id)
        search_indicator_outer_html = search_indicator.outerHtml if search_indicator
        if status == 'hide'
          return true if search_indicator_outer_html and !search_indicator_outer_html.include?('style="DISPLAY: none"')
        else
          return true if search_indicator_outer_html and search_indicator_outer_html.include?('style="DISPLAY: none"')
        end
        sleep check_interval if check_interval > 0 and check_interval < 5 * 60 # wait max 5 minutes
        count += 1
      end
      return false
    end
def ajax_wait_for_element(element_id, seconds, status='show', check_interval = $testwise_polling_interval)
      count = 0
      check_interval = 1 if check_interval < 1 or check_interval > seconds
      while count < (seconds / check_interval) do
        search_indicator = @web_browser.element_by_id(element_id)
        search_indicator_outer_html = search_indicator.outerHtml if search_indicator
        if status == 'hide'
          return true if search_indicator_outer_html and !search_indicator_outer_html.include?('style="DISPLAY: none"')
        else
          return true if search_indicator_outer_html and search_indicator_outer_html.include?('style="DISPLAY: none"')
        end
        sleep check_interval if check_interval > 0 and check_interval < 5 * 60 # wait max 5 minutes
        count += 1
      end
      return false
    end
Wait for specific seconds for an Ajax update finish.
 Trick: In your Rails application,
     :loading 	=> "Element.show('search_indicator');
     :complete	=> "Element.hide('search_indicator');

   <%= image_tag("indicator.gif", :id => 'search_indicator', :style => 'display:none') %>

 Typical usage:
    ajax_wait_for_element("search_indicator", 30)
    ajax_wait_for_element("search_indicator", 30, "show")
    ajax_wait_for_element("search_indicator", 30, "hide")
    ajax_wait_for_element("search_indicator", 30, "show", 5) # check every 5 seconds

 Warning: this method has not been fully tested, if you are not using Rails, change your parameter accordingly.