<commit_before>from dimagi.utils.django.test import SeleniumWrapper
from corehq.apps.selenium.testcases import MobileWorkerTestCase
from selenium.common.exceptions import NoSuchElementException
from corehq.apps import selenium

DEFAULT_OPEN_FORM_WAIT_TIME = 10
DEFAULT_SUBMIT_FORM_WAIT_TIME = 5


class CloudCareQuestion(object):
    """
    Selenium WebElement wrapper class with convenience methods for questions.

    """
    def __init__(self, element):
        # element is a fully loaded question - we can assume any finds can
        # return immediately
        self.element = SeleniumWrapper(element=element)

    def __getattr__(self, name):
        return getattr(self.element, name)

    def set_value(self, value):
        try:
            # text input
            self.find_element_by_xpath(
                "div[@id='widget']/input", duration=0
            ).send_keys(value)
        except NoSuchElementException:
            # radio buttons
            self.find_element_by_xpath(
                "div[@id='widget']//span[@id='label' and text()='%s']" % value,
                duration=0
            ).click()

            # todo: other non-text inputs (?)

        # todo: click outside to trigger validation

class CloudCareTestCase(MobileWorkerTestCase):
    """
    Base TestCase for cloudcare with convenience methods.<commit_msg>selenium wrapper api change<commit_after>from dimagi.utils.django.test import SeleniumWrapper
from corehq.apps.selenium.testcases import MobileWorkerTestCase
from selenium.common.exceptions import NoSuchElementException
from corehq.apps import selenium

DEFAULT_OPEN_FORM_WAIT_TIME = 10
DEFAULT_SUBMIT_FORM_WAIT_TIME = 5


class CloudCareQuestion(object):
    """
    Selenium WebElement wrapper class with convenience methods for questions.

    """
    def __init__(self, element):
        # element is a fully loaded question - we can assume any finds can
        # return immediately
        self.element = SeleniumWrapper(element)

    def __getattr__(self, name):
        return getattr(self.element, name)

    def set_value(self, value):
        try:
            # text input
            self.find_element_by_xpath(
                "div[@id='widget']/input", duration=0
            ).send_keys(value)
        except NoSuchElementException:
            # radio buttons
            self.find_element_by_xpath(
                "div[@id='widget']//span[@id='label' and text()='%s']" % value,
                duration=0
            ).click()

            # todo: other non-text inputs (?)

        # todo: click outside to trigger validation

class CloudCareTestCase(MobileWorkerTestCase):
    """
    Base TestCase for cloudcare with convenience methods.
{'fraction_non_alphanumeric': 0.08450184501845018, 'fraction_numerical': 0.0036900369003690036, 'mean_word_length': 2.734159779614325, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6953739', 'n_tokens_mistral': 751, 'n_tokens_neox': 707, 'n_words': 194}