<commit_before>import logging
import os

from aloe import step, world
from aloe.registry import STEP_REGISTRY
from aloe_webdriver.webdriver import contains_content

from nose.tools import assert_true, assert_equal

from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.alert import Alert

from . import utils

from collections import OrderedDict
import time

logger = logging.getLogger(__name__)

# Clearing all the aloe step definitions before we register our own.
STEP_REGISTRY.clear()


@step('I try to log in')
def try_to_login(step):
    world.browser.get(world.site_url + "login?next=/router/")


@step ('I should be logged in as an Angelman user called "([^"]+)"')
def login_as_angelman_user(step, user_name):
    world.expected_login_message = "Welcome {0} to the Angelman Registry".format(user_name)


@step('I should be at the welcome page and see a message which says "([^"]+)"')
def angelman_user_logged_in(step, welcome_message):
    login_message = world.browser.find_element_by_tag_name('h4').text

    # Ensure that the user sees the expected page after successfully logging in
    assert world.expected_login_message in login_message


@step('the administrator manually activates the user')
def try_to_manually_activate_new_user(step):
    world.browser.get(world.site_url + "admin/registration/registrationprofile/")
    world.browser.find_element_by_id('action-toggle').send_keys(Keys.SPACE)

    world.browser.find_element_by_xpath("//select[@name='action']/option[text()='Activate users']").click()
    world.browser.find_element_by_xpath("//*[@title='Run the selected action']").click()


@step('the user should be activated')
def check_user_activated(step):
    # Ensure that the user has been successfully activated by checking for the green tick icon
    assert not (world.browser.find_elements_by_css_selector('img[src$="/static/admin/img/icon-yes.svg"].ng-hide'))

    # Log out as the admin user
    world.browser.get(world.site_url + "logout?next=/router/")


@step('I try to register as an "([^"]+)" user called "([^"]+)" using the email address "([^"]+)" and the password "([^"]+)"')
def try_to_register(step, registry, client_name, email_address, password):
    registry_code = ''

    if registry == 'Angelman':
        registry_code = 'ang'

    world.browser.get(world.site_url + registry_code + "/register")

    client_first_name = client_name.split()[0]
    client_last_name = client_name.split()[1]

    # Plain text field parameters
    params = OrderedDict([
        ('id_username', email_address),
        ('id_password1', password),
        ('id_password2', password),
        ('id_parent_guardian_first_name', client_first_name),
        ('id_parent_guardian_last_name', client_last_name),
        ('id_parent_guardian_date_of_birth', '1980-09-01'),
        # Gender radio button
        ('id_parent_guardian_address', 'Australia'),
        ('id_parent_guardian_suburb', 'Australia'),
        # Country dropdown
        # State dropdown
        ('id_parent_guardian_postcode', '6000'),
        ('id_parent_guardian_phone', '98765432')
    ])

    # Populate plain text fields
    for key, value in params.items():
        world.browser.find_element_by_id(key).send_keys(value + Keys.TAB)

    # Select the gender radio button
    # 1 - Male, 2 - Female, 3 - Indeterminate
    world.browser.find_element_by_css_selector("input[type='radio'][value='1']").click()

    # Select the country and state dropdowns
    world.browser.find_element_by_xpath("//select[@name='parent_guardian_country']/option[text()='Australia']").click()
    world.browser.find_element_by_xpath("//select[@name='parent_guardian_state']/option[text()='Western Australia']").click()

    # Fill out the patient details
    world.browser.find_element_by_id('ui-id-2').click()

    patient_params = OrderedDict([
        ('id_first_name', 'Patient_First'),
        ('id_surname', 'Patient_Surname'),
        ('id_date_of_birth', '1985-01-01'),
        # Gender radio button
        # "Same details" checkbox
    ])

    for key, value in patient_params.items():
        world.browser.find_element_by_id(key).send_keys(value + Keys.TAB)

    radio = world.browser.find_element_by_id('id_gender')
    world.browser.execute_script("arguments[0].click();", radio)

    world.browser.find_element_by_id('same_address').send_keys(Keys.SPACE)

    captcha_iframe_element = world.browser.find_element_by_xpath("//iframe[@role='presentation']")
    world.browser.switch_to.frame(captcha_iframe_element)
    utils.scroll_to_y(500)

    captcha_element = world.browser.find_element_by_id('recaptcha-anchor').send_keys(Keys.SPACE)

    time.sleep(4)
    world.browser.switch_to_default_content()
    world.browser.find_element_by_id('registration-submit').click()


@step('I should have successfully registered and would see a "([^"]+)" message')
def registration_successful(step, expected_success_message):
    # Ensure that the registration has successfully completed
    actual_message = world.browser.find_element_by_tag_name('h3').text
    assert expected_success_message in actual_message


@step('I try to surf the site...')
def sleep_for_admin(step):<commit_msg>testing recaptcha check<commit_after>import logging
import os

from aloe import step, world
from aloe.registry import STEP_REGISTRY
from aloe_webdriver.webdriver import contains_content

from nose.tools import assert_true, assert_equal

from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.alert import Alert

from . import utils

from collections import OrderedDict
import time

logger = logging.getLogger(__name__)

# Clearing all the aloe step definitions before we register our own.
STEP_REGISTRY.clear()


@step('I try to log in')
def try_to_login(step):
    world.browser.get(world.site_url + "login?next=/router/")


@step ('I should be logged in as an Angelman user called "([^"]+)"')
def login_as_angelman_user(step, user_name):
    world.expected_login_message = "Welcome {0} to the Angelman Registry".format(user_name)


@step('I should be at the welcome page and see a message which says "([^"]+)"')
def angelman_user_logged_in(step, welcome_message):
    login_message = world.browser.find_element_by_tag_name('h4').text

    # Ensure that the user sees the expected page after successfully logging in
    assert world.expected_login_message in login_message


@step('the administrator manually activates the user')
def try_to_manually_activate_new_user(step):
    world.browser.get(world.site_url + "admin/registration/registrationprofile/")
    world.browser.find_element_by_id('action-toggle').send_keys(Keys.SPACE)

    world.browser.find_element_by_xpath("//select[@name='action']/option[text()='Activate users']").click()
    world.browser.find_element_by_xpath("//*[@title='Run the selected action']").click()


@step('the user should be activated')
def check_user_activated(step):
    # Ensure that the user has been successfully activated by checking for the green tick icon
    assert not (world.browser.find_elements_by_css_selector('img[src$="/static/admin/img/icon-yes.svg"].ng-hide'))

    # Log out as the admin user
    world.browser.get(world.site_url + "logout?next=/router/")


@step('I try to register as an "([^"]+)" user called "([^"]+)" using the email address "([^"]+)" and the password "([^"]+)"')
def try_to_register(step, registry, client_name, email_address, password):
    registry_code = ''

    if registry == 'Angelman':
        registry_code = 'ang'

    world.browser.get(world.site_url + registry_code + "/register")

    client_first_name = client_name.split()[0]
    client_last_name = client_name.split()[1]

    # Plain text field parameters
    params = OrderedDict([
        ('id_username', email_address),
        ('id_password1', password),
        ('id_password2', password),
        ('id_parent_guardian_first_name', client_first_name),
        ('id_parent_guardian_last_name', client_last_name),
        ('id_parent_guardian_date_of_birth', '1980-09-01'),
        # Gender radio button
        ('id_parent_guardian_address', 'Australia'),
        ('id_parent_guardian_suburb', 'Australia'),
        # Country dropdown
        # State dropdown
        ('id_parent_guardian_postcode', '6000'),
        ('id_parent_guardian_phone', '98765432')
    ])

    # Populate plain text fields
    for key, value in params.items():
        world.browser.find_element_by_id(key).send_keys(value + Keys.TAB)

    # Select the gender radio button
    # 1 - Male, 2 - Female, 3 - Indeterminate
    world.browser.find_element_by_css_selector("input[type='radio'][value='1']").click()

    # Select the country and state dropdowns
    world.browser.find_element_by_xpath("//select[@name='parent_guardian_country']/option[text()='Australia']").click()
    world.browser.find_element_by_xpath("//select[@name='parent_guardian_state']/option[text()='Western Australia']").click()

    # Fill out the patient details
    world.browser.find_element_by_id('ui-id-2').click()

    patient_params = OrderedDict([
        ('id_first_name', 'Patient_First'),
        ('id_surname', 'Patient_Surname'),
        ('id_date_of_birth', '1985-01-01'),
        # Gender radio button
        # "Same details" checkbox
    ])

    for key, value in patient_params.items():
        world.browser.find_element_by_id(key).send_keys(value + Keys.TAB)

    radio = world.browser.find_element_by_id('id_gender')
    world.browser.execute_script("arguments[0].click();", radio)

    world.browser.find_element_by_id('same_address').send_keys(Keys.SPACE)

    #captcha_iframe_element = world.browser.find_element_by_xpath("//iframe[@role='presentation']")
    captcha_iframe_element = world.browser.find_element_by_xpath("//iframe[@title='recaptcha widget']")

    world.browser.switch_to.frame(captcha_iframe_element)
    utils.scroll_to_y(500)

    captcha_element = world.browser.find_element_by_id('recaptcha-anchor').send_keys(Keys.SPACE)

    time.sleep(4)
    world.browser.switch_to_default_content()
    world.browser.find_element_by_id('registration-submit').click()


@step('I should have successfully registered and would see a "([^"]+)" message')
def registration_successful(step, expected_success_message):
    # Ensure that the registration has successfully completed
    actual_message = world.browser.find_element_by_tag_name('h3').text
    assert expected_success_message in actual_message


@step('I try to surf the site...')
def sleep_for_admin(step):
{'fraction_non_alphanumeric': 0.1252617551875119, 'fraction_numerical': 0.008566533409480296, 'mean_word_length': 4.618716577540107, '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': '1047590', 'n_tokens_mistral': 3377, 'n_tokens_neox': 3183, 'n_words': 686}