Module: Register
- Extended by:
- LapisLazuli
- Defined in:
- lib/lapis_lazuli/generators/cucumber/template/features/helpers/registration_helper.rb
Constant Summary
Constants included from LapisLazuli
LapisLazuli::CONFIG_OPTIONS, LapisLazuli::PLACEHOLDERS, LapisLazuli::VERSION
Constants included from LapisLazuli::ArgParse
LapisLazuli::ArgParse::ERROR_OPTIONS
Constants included from LapisLazuli::WorldModule::Hooks
LapisLazuli::WorldModule::Hooks::HOOK_QUEUES
Instance Attribute Summary
Attributes included from LapisLazuli
Class Method Summary collapse
- .biography_field ⇒ Object
-
.ensure_open_registrarion ⇒ Object
And finally as function that ensures an action was successfully completed.
- .ensure_registered(user) ⇒ Object
- .experience_field ⇒ Object
- .fill_form ⇒ Object
-
.form ⇒ Object
This is a list of elements relevant for this helper.
-
.gender_radio(gender) ⇒ Object
@formatter:on.
-
.is_registration_open? ⇒ Boolean
Second, a function that confirms that the action was successful.
- .open_register_button ⇒ Object
-
.open_registration ⇒ Object
The following 3 functions are a typical example of something to use.
- .password_field ⇒ Object
- .policy_checkbox ⇒ Object
- .register_user ⇒ Object
- .registration_result ⇒ Object
- .select_experiences(*experience_list) ⇒ Object
- .submit_button ⇒ Object
- .submit_form ⇒ Object
- .username_field ⇒ Object
Methods included from LapisLazuli
After, Before, Start, fetch_versions
Methods included from LapisLazuli::Assertions
Methods included from LapisLazuli::GenericModule::XPath
#xp_and, #xp_contains, #xp_not, #xp_or
Methods included from LapisLazuli::WorldModule::API
Methods included from LapisLazuli::WorldModule::Browser
Methods included from LapisLazuli::WorldModule::Browser::ClassMethods
#browser_module, #browser_modules
Methods included from LapisLazuli::WorldModule::Proxy
Methods included from LapisLazuli::WorldModule::Logging
Methods included from LapisLazuli::WorldModule::Config
#add_config_from_file, #config, #current_env, #env, #env_or_config, #get_config_from_file, #has_config?, #has_env?, #has_env_or_config?, #init, #load_config, #metadata, #var_from_env
Methods included from LapisLazuli::WorldModule::Config::ClassMethods
#add_config, #config_file, #config_file=, #config_files
Methods included from LapisLazuli::WorldModule::Error
Methods included from LapisLazuli::WorldModule::Annotate
Methods included from LapisLazuli::ArgParse
#make_list_from_item, #make_list_from_nested, #parse_args
Methods included from LapisLazuli::WorldModule::Variable
#has_storage?, #scenario, #storage, #time, #uuid, #variable, #variable!
Methods included from LapisLazuli::WorldModule::Hooks
add_hook, #after_scenario_hook, #before_scenario_hook
Class Method Details
.biography_field ⇒ Object
14 |
# File 'lib/lapis_lazuli/generators/cucumber/template/features/helpers/registration_helper.rb', line 14 def biography_field; browser.find(:like => [:textarea, :id, 'register-bio']); end |
.ensure_open_registrarion ⇒ Object
And finally as function that ensures an action was successfully completed.
49 50 51 52 |
# File 'lib/lapis_lazuli/generators/cucumber/template/features/helpers/registration_helper.rb', line 49 def ensure_open_registrarion Auth.ensure_log_out Register.open_registration unless Register.is_registration_open? end |
.ensure_registered(user) ⇒ Object
82 83 84 85 86 87 88 89 90 |
# File 'lib/lapis_lazuli/generators/cucumber/template/features/helpers/registration_helper.rb', line 82 def ensure_registered(user) begin Auth.ensure_log_in(user) Auth.log_out rescue Exception => e Register.ensure_open_registrarion Register.register_user end end |
.experience_field ⇒ Object
13 |
# File 'lib/lapis_lazuli/generators/cucumber/template/features/helpers/registration_helper.rb', line 13 def experience_field; browser.find(:like => [:select, :id, "register-experience"], :context => form); end |
.fill_form ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/lapis_lazuli/generators/cucumber/template/features/helpers/registration_helper.rb', line 54 def fill_form Register.username_field.set(User.get('username')) Register.password_field.set(User.get('password')) Register.gender_radio(User.get('gender')).click Register.select_experiences(User.get('experience').split(',')) Register.biography_field.set(User.get('biography')) Register.policy_checkbox.set((User.get('complete_all').to_i == 1)) end |
.form ⇒ Object
This is a list of elements relevant for this helper. The following is short notation, only use this if the element selector can be done in 1 line. @formatter:off
9 |
# File 'lib/lapis_lazuli/generators/cucumber/template/features/helpers/registration_helper.rb', line 9 def form; browser.wait(:like => [:form, :id, 'form-register']); end |
.gender_radio(gender) ⇒ Object
@formatter:on
19 20 21 22 23 24 25 |
# File 'lib/lapis_lazuli/generators/cucumber/template/features/helpers/registration_helper.rb', line 19 def gender_radio(gender) browser.find( :label => {:text => /#{gender}/i}, :context => Register.form, :message => "Unable to find gender `#{gender}`, are you sure it's an option to select?" ) end |
.is_registration_open? ⇒ Boolean
Second, a function that confirms that the action was successful
44 45 46 |
# File 'lib/lapis_lazuli/generators/cucumber/template/features/helpers/registration_helper.rb', line 44 def is_registration_open? return Register.form rescue false end |
.open_register_button ⇒ Object
10 |
# File 'lib/lapis_lazuli/generators/cucumber/template/features/helpers/registration_helper.rb', line 10 def ; browser.find(:like => [:button, :id, 'button-register']); end |
.open_registration ⇒ Object
The following 3 functions are a typical example of something to use. First a function in which you perform an action (open_something, click_something, press_something)
39 40 41 |
# File 'lib/lapis_lazuli/generators/cucumber/template/features/helpers/registration_helper.rb', line 39 def open_registration Register..click end |
.password_field ⇒ Object
12 |
# File 'lib/lapis_lazuli/generators/cucumber/template/features/helpers/registration_helper.rb', line 12 def password_field; browser.find(:element => {:name => 'password'}, :context => Register.form); end |
.policy_checkbox ⇒ Object
15 |
# File 'lib/lapis_lazuli/generators/cucumber/template/features/helpers/registration_helper.rb', line 15 def policy_checkbox; browser.find(:like => [:input, :id, 'register-complete-all']) end |
.register_user ⇒ Object
67 68 69 70 |
# File 'lib/lapis_lazuli/generators/cucumber/template/features/helpers/registration_helper.rb', line 67 def register_user Register.fill_form Register.submit_form end |
.registration_result ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/lapis_lazuli/generators/cucumber/template/features/helpers/registration_helper.rb', line 72 def registration_result alert = browser.wait(like: [:div, :class, 'alert'], timeout: 2, throw: false) if alert.nil? return false, 'No message was displayed after registering' elsif !alert.text.include? User.get('username') return false, "An error message did display, but didn't contain the expected text: `#{alert.text}`" end return true, 'Successfully found the success message' end |
.select_experiences(*experience_list) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/lapis_lazuli/generators/cucumber/template/features/helpers/registration_helper.rb', line 27 def select_experiences(*experience_list) experience_list.each do |exp| option = browser.find( :option => {:value => /#{exp}/i}, :context => Register.experience_field ) option.click(:control) end end |
.submit_button ⇒ Object
16 |
# File 'lib/lapis_lazuli/generators/cucumber/template/features/helpers/registration_helper.rb', line 16 def ; browser.find(:button => {:id => 'button-save'}, :context => Register.form); end |
.submit_form ⇒ Object
63 64 65 |
# File 'lib/lapis_lazuli/generators/cucumber/template/features/helpers/registration_helper.rb', line 63 def submit_form Register..click end |