def GetInfobarIndexByType(test, infobar_type, windex=0, tab_index=0):
  """Returns the index of the infobar of the given type.

  Args:
    test: Derived from pyauto.PyUITest - base class for UI test cases.
    infobar_type: The infobar type to look for.
    windex: Window index.
    tab_index: Tab index.

  Returns:
    Index of infobar for infobar type, or None if not found.
  """
  infobar_list = (
      test.GetBrowserInfo()['windows'][windex]['tabs'][tab_index] \
          ['infobars'])
  for infobar in infobar_list:
    if infobar_type == infobar['type']:
      return infobar_list.index(infobar)
  return None