<commit_before>"""Webdriver support for lettuce"""
import time

from lettuce import step
from lettuce import world

from lettuce_webdriver.util import assert_true
from lettuce_webdriver.util import assert_false
from lettuce_webdriver.util import AssertContextManager
from lettuce_webdriver.util import find_button
from lettuce_webdriver.util import find_field
from lettuce_webdriver.util import find_option

from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import \
    NoSuchElementException, \
    StaleElementReferenceException


def contains_content(browser, content):
    for elem in browser.find_elements_by_xpath(
        '//*[contains(normalize-space(text()), "%s")]' % content):
        try:
            if elem.is_displayed():
                return True
        except StaleElementReferenceException:
            pass

    return False

def wait_for_elem(browser, xpath, timeout=15):
    start = time.time()
    elems = []
    while time.time() - start < timeout:
        elems = browser.find_elements_by_xpath(xpath)
        if elems:<commit_msg>Updated contains_content to select more relevant nodes.<commit_after>"""Webdriver support for lettuce"""
import time

from lettuce import step
from lettuce import world

from lettuce_webdriver.util import assert_true
from lettuce_webdriver.util import assert_false
from lettuce_webdriver.util import AssertContextManager
from lettuce_webdriver.util import find_button
from lettuce_webdriver.util import find_field
from lettuce_webdriver.util import find_option

from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import \
    NoSuchElementException, \
    StaleElementReferenceException


def contains_content(browser, content):
    for elem in browser.find_elements_by_xpath(
        '//*[contains(normalize-space(.),"{content}") ' \
        'and not(./*[contains(normalize-space(.),"{content}")])]' \
        .format(content=content)):

        try:
            if elem.is_displayed():
                return True
        except StaleElementReferenceException:
            pass

    return False

def wait_for_elem(browser, xpath, timeout=15):
    start = time.time()
    elems = []
    while time.time() - start < timeout:
        elems = browser.find_elements_by_xpath(xpath)
        if elems:
{'fraction_non_alphanumeric': 0.08027621924902892, 'fraction_numerical': 0.0017263703064307294, 'mean_word_length': 3.730612244897959, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '3197083', 'n_tokens_mistral': 660, 'n_tokens_neox': 624, 'n_words': 170}