title: Selenium Webdriver Python I am trying to wait until data has completed processing in a html table. How do i know when the table is blank
body: <p>I have a webpage with a HTML table of 1 row and some columns.
  The user selects the checkbox and then clicks the run button.
  A process starts to run, data starts to be processed.
  The HTML table, the column called "Progress" will show a progress bar with a percentage of how much has been completed.  It will show 100% when completed.
  All the data shown in the columns, e.g. Name, company, Progress will go blank.
  This means the process has completed.</p>
  
  <p>Is there a way I can wait for the table to be empty, no data is being shown and then I know the processing has compelted.  I can then move onto the next test?</p>
  
  <p>I have first tried to wait for all of the rows and columns of the table to be loaded and then print out the Name and Company columns using WebDriverWait.</p>
  
  <pre><code>WebDriverWait(self.driver, 20).until(EC.presence_of_element_located((By.ID, 'operations_monitoring_tab_current_ct_fields_body')))
  </code></pre>
  
  <p>I get the error: </p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Webdriver\ClearCore\TestCases\OperationsPage_TestCase.py", line 101, in test_add_and_run_clean_process
      process_lists_page.has_process_run_completed()
    File "C:\Webdriver\ClearCore\Pages\operations.py", line 239, in has_process_run_completed
      print col_name.text
    File "C:\Python27\lib\encodings\cp1252.py", line 12, in encode
      return codecs.charmap_encode(input,errors,encoding_table)
  UnicodeEncodeError: 'charmap' codec can't encode character u'\u25ba' in position 0: character maps to &lt;undefined&gt;
  </code></pre>
  
  <p>My method so far is (operations.py):</p>
  
  <pre><code>from selenium.webdriver.support import expected_conditions as EC
  from selenium.webdriver.common.by import By
  from selenium.webdriver.support.ui import WebDriverWait
  from selenium.webdriver.support.ui import Select
  from selenium.common.exceptions import NoSuchElementException
  
  def has_process_run_completed(self):
      try:
          WebDriverWait(self.driver, 20).until(EC.presence_of_element_located((By.ID, 'operations_monitoring_tab_current_ct_fields_body')))
          table_id = WebDriverWait(self.driver, 20).until(EC.presence_of_element_located((By.ID, 'operations_monitoring_tab_current_ct_fields_body')))
          rows = table_id.find_elements(By.TAG_NAME, "tr")
          for row in rows:
              # Get the columns
              col_name = row.find_elements(By.TAG_NAME, "td")[1]  # This is the Name column
              col_company = row.find_elements(By.TAG_NAME, "td")[2]  # This is the Company column
              #col_progress = row.find_elements(By.TAG_NAME, "td")[3]  # This is the progress column
              #col_status = row.find_elements(By.TAG_NAME, "td")[4]  # This is the Status column
              print col_name.text
              print col_company.text
              #print col_progress.text
              #print col_status.text
              return True
      except NoSuchElementException, e:
              return False
  </code></pre>
  
  <p>From my TestCase class OpeationsPage_TestCase.py to call the method is:</p>
  
  <pre><code>from Menus.project_navigator import ProjectNavigatorPage    
  class OperationsPage_TestCase(BaseTestCase):
  
  process_lists_page = project_navigator.select_projectNavigator_item("Process Lists") 
  process_lists_page.click_checkbox_for_the_process("LADemo")
  process_lists_page.click_run_and_monitor_button()
  process_lists_page.has_process_run_completed()
  </code></pre>
  
  <p>The HTML of the table is:</p>
  
  <pre><code>&lt;table id="operations_monitoring_tab_current_ct_fields_body" cellspacing="0" style="table-layout: fixed; width: 100%;"&gt;
      &lt;colgroup&gt;
          &lt;col style="width: 30px;" /&gt;
          &lt;col style="width: 78px;" /&gt;
          &lt;col style="width: 42px;" /&gt;
          &lt;col style="width: 205px;" /&gt;
          &lt;col style="width: 55px;" /&gt;
          &lt;col style="width: 202px;" /&gt;
          &lt;col style="width: 40px;" /&gt;
      &lt;/colgroup&gt;
      &lt;tbody&gt;
          &lt;tr class="GPI5XK1CFG GPI5XK1CMG" __gwt_subrow="0" __gwt_row="0"&gt;
              &lt;td class="GPI5XK1CEG GPI5XK1CGG GPI5XK1CNG" __gwt_cell="cell-gwt-uid-282" style="outline-style:none;"&gt;
                  &lt;input type="checkbox" tabindex="-1" /&gt;
              &lt;/td&gt;
              &lt;td class="GPI5XK1CEG GPI5XK1CGG GPI5XK1CNG" __gwt_cell="cell-gwt-uid-283" style="outline-style:none;"&gt;
                  &lt;span&gt;
  &lt;span class="" title="" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;cursor:pointer;"&gt;►&lt;/span&gt;
                  &lt;/span&gt;
                  &lt;span&gt;
  &lt;span class="" title="LADemo" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;cursor:pointer;padding-left:3px;"&gt;LADemo&lt;/span&gt;
                  &lt;/span&gt;
              &lt;/td&gt;
              &lt;td class="GPI5XK1CEG GPI5XK1CGG GPI5XK1CNG" __gwt_cell="cell-gwt-uid-284" style="outline-style:none;"&gt;
                  &lt;span class="" title="" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;padding-right: 1px;" /&gt;
              &lt;/td&gt;
              &lt;td class="GPI5XK1CEG GPI5XK1CGG GPI5XK1CNG" __gwt_cell="cell-gwt-uid-285" style="outline-style:none;"&gt;
                  &lt;div class="" title="" style="border-left:2px solid #9EC400;border-right:2px solid #9EC400;border-radius:5px;margin-right:2px;"&gt;
                      &lt;div class="" title="9%" style="border-left:2px solid #9EC400;border-right:2px solid #9EC400;border-radius:5px;box-shadow:0 8px 6px -6px #bbb;text-shadow:0px 2px 2px rgba(0, 0, 0, 0.4);text-align: center;background-color: #9EC400;width:9%;"&gt;9%&lt;/div&gt;
                  &lt;/div&gt;
              &lt;/td&gt;
              &lt;td class="GPI5XK1CEG GPI5XK1CGG GPI5XK1CNG" __gwt_cell="cell-gwt-uid-286" style="outline-style:none;"&gt;
                  &lt;div class="" title="Running" style="text-align:center;padding-top:3px;"&gt;
                      &lt;img border="0" style="width:16px;height:16px;background:url(data:image/gif;base64,R0lGODlhEAAQAKUAAJzGBNzuhPT6zNT2PPz+jPz+5OT6hLziHQQA7) no-repeat 0px 0px;" src="http://mypc.companyname.local:8080/clearcore/ClearCore/clear.cache.gif" onload="this.__gwtLastUnhandledEvent=" load ";"/&gt;
                  &lt;/div&gt;
              &lt;/td&gt;
              &lt;td class="GPI5XK1CEG GPI5XK1CGG GPI5XK1CNG" __gwt_cell="cell-gwt-uid-287" style="outline-style:none;"&gt;
                  &lt;span class="" title="LADEMO_IE_10_16_1521_18_58" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;padding-right: 1px;"&gt;LADEMO_IE_10_16_1521_18_58&lt;/span&gt;
              &lt;/td&gt;
              &lt;td class="GPI5XK1CEG GPI5XK1CGG GPI5XK1CNG" __gwt_cell="cell-gwt-uid-288" style="outline-style:none;"&gt;
                  &lt;span class="" title="" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;padding-right: 1px;" /&gt;
              &lt;/td&gt;
              &lt;td class="GPI5XK1CEG GPI5XK1CGG GPI5XK1CNG" __gwt_cell="cell-gwt-uid-289" style="outline-style:none;"&gt;
                  &lt;span class="" title="" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;padding-right: 1px;" /&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>I would like to poll the table and check is there any data shown in the columns.  It could even be just 1 of the columns.  When it is empty return true.  This way I know that the table is empty and the data processing has completed.
  Is there a way to do it using a While loop perhaps?</p>
  
  <p>Some help appreciated.  Thank you.
  Riaz</p>