<commit_before>from behave import step
import behaving.web.steps  # NOQA


@step(u'I should see at least {count:d} elements with the css selector "{css}"')
def should_see_at_least_count_elements_with_css(context, css, count):
    element_count = len(context.browser.find_by_css(css))
    assert element_count >= count, u'Element has at least that many counts'


@step(u'I should see {count:d} elements with the css selector "{css}"')
def should_see_count_elements_with_css(context, css, count):
    element_count = len(context.browser.find_by_css(css))
    assert element_count == count, u'Found %d (expected %d)' % (element_count, count)


@step(u'I should see exactly one element with the css selector "{css}" containing the text "{text}"')
def should_see_element_with_css_and_text(context, css, text):
    elements = context.browser.find_by_css(css)
    assert len(elements) == 1
    assert elements.first.text == text
<commit_msg>Make behave step more robust.<commit_after>from behave import step
import behaving.web.steps  # NOQA


def is_text_present_in_element_by_css(self, selector, text, wait_time=None):
    import time
    wait_time = wait_time or self.wait_time
    end_time = time.time() + wait_time

    while time.time() < end_time:
        try:
            self.driver.find_element_by_css_selector(selector).text.index(text)
            return True
        except ValueError:
            pass
        except NoSuchElementException:
            # This exception will be thrown if the body tag isn't present
            # This has occasionally been observed. Assume that the
            # page isn't fully loaded yet
            pass
    return False


@step(u'I should see at least {count:d} elements with the css selector "{css}"')
def should_see_at_least_count_elements_with_css(context, css, count):
    element_count = len(context.browser.find_by_css(css))
    assert element_count >= count, u'Element has at least that many counts'


@step(u'I should see {count:d} elements with the css selector "{css}"')
def should_see_count_elements_with_css(context, css, count):
    element_count = len(context.browser.find_by_css(css))
    assert element_count == count, u'Found %d (expected %d)' % (element_count, count)


@step(u'I should see exactly one element with the css selector "{css}" containing the text "{text}"')
def should_see_element_with_css_and_text(context, css, text):
    elements = context.browser.find_by_css(css)
    assert len(elements) == 1
    assert is_text_present_in_element_by_css(context.browser, css, text)

{'fraction_non_alphanumeric': 0.09576138147566719, 'fraction_numerical': 0.0007849293563579278, 'mean_word_length': 4.244855967078189, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1360026', 'n_tokens_mistral': 779, 'n_tokens_neox': 761, 'n_words': 232}