11from behave import when
2+ from datetime import datetime
3+ from dateutil .relativedelta import relativedelta
24
35
46@when ('I submit my participant id' )
57def when_I_submit_my_participant_id (context ):
8+ if not hasattr (context , 'participant_id' ):
9+ context .participant_id = 'abc123'
610 context .page .fill ('input[name="participant_id"]' , context .participant_id )
711 context .page .click ('button[type="submit"]' )
812
@@ -19,6 +23,14 @@ def when_I_fill_in_and_submit_my_date_of_birth(context, date_of_birth):
1923 context .page .get_by_label ('Year' ).fill (year )
2024 context .page .click ("text=Continue" )
2125
26+ @when (u'I fill in and submit my date of birth as {years} years ago' )
27+ def when_I_fill_in_and_submit_my_date_of_birth_as_x_years_ago (context , years ):
28+ date_of_birth = datetime .now () - relativedelta (years = int (years ))
29+ context .page .get_by_label ('Day' ).fill (str (date_of_birth .day ))
30+ context .page .get_by_label ('Month' ).fill (str (date_of_birth .month ))
31+ context .page .get_by_label ('Year' ).fill (str (date_of_birth .year ))
32+ context .page .click ("text=Continue" )
33+
2234@when (u'I fill in and submit my height with "{height}"' )
2335def when_I_fill_in_and_submit_my_height (context , height ):
2436 context .page .get_by_label ('Centimetre' ).fill (height )
@@ -43,12 +55,32 @@ def stone_and_pounds(context, stone, pounds):
4355 context .page .get_by_label ('Pounds' ).fill (pounds )
4456 context .page .click ("text=Continue" )
4557
58+ @when (u'I fill in and submit my sex at birth with "{sex_at_birth}"' )
59+ def when_I_fill_in_and_submit_my_sex_at_birth (context , sex_at_birth ):
60+ context .page .get_by_label (sex_at_birth , exact = True ).check ()
61+ context .page .click ("text=Continue" )
62+
63+ @when (u'I fill in and submit my gender with "{gender}"' )
64+ def when_I_fill_in_and_submit_my_gender (context , gender ):
65+ context .page .get_by_label (gender , exact = True ).check ()
66+ context .page .click ("text=Continue" )
67+
68+ @when (u'I fill in and submit my ethnicity with "{ethnicity}"' )
69+ def when_I_fill_in_and_submit_my_ethnicity (context , ethnicity ):
70+ context .page .get_by_label (ethnicity , exact = True ).check ()
71+ context .page .click ("text=Continue" )
72+
4673@when (u'I fill in and submit my respiratory conditions with "{condition_a}" and "{condition_b}"' )
4774def when_I_fill_in_and_submit_my_respiratory_conditions (context , condition_a , condition_b ):
4875 context .page .get_by_label (condition_a ).check ()
4976 context .page .get_by_label (condition_b ).check ()
5077 context .page .click ("text=Continue" )
5178
79+ @when (u'I fill in and submit my asbestos exposure with "{asbestos_exposure}"' )
80+ def when_I_fill_in_and_submit_my_asbestos_exposure (context , asbestos_exposure ):
81+ context .page .get_by_label (asbestos_exposure , exact = True ).check ()
82+ context .page .click ("text=Continue" )
83+
5284@when ('I submit the form' )
5385def when_I_submit_the_form (context ):
5486 context .page .click ("text=Continue" )
0 commit comments