'Checks the number of \'pattern\' occurrences in the current browser page'

def check_string_count_in_page(self, pattern, min_count, max_count=None):

    page = self.last_page()
    pattern_count = page.count(pattern)
    if (max_count is None):
        max_count = min_count
    if ((pattern_count < min_count) or (pattern_count > max_count)):
        fname = self.write_temp_file(page)
        errmsg = ("%i    occurrences    of    '%s'    found    (min.    %i,    max.    %i).\npage    content    written    to    '%s'    " % (pattern_count, pattern, min_count, max_count, fname))
        raise AssertionError(errmsg)
