Module: Navigation
- Includes:
- Utilities
- Included in:
- AwardObject, AwardTransactionObject, BudgetColumnObject, BudgetPeriodObject, BudgetPersonnelObject, BudgetVersionsObject, CommitteeDocumentObject, ComplianceQuestionsObject, CostSharingObject, CustomDataObject, FinancialEntityObject, GroupAssigneeObject, GroupObject, IPCostSharingObject, IPReviewObject, IPUnrecoveredFAObject, IRBProtocolDevelopmentObject, InstituteRateObject, InstitutionalProposalObject, KeyPersonObject, KualiUniversityQuestionsObject, PHSFellowshipQuestionnaireObject, PermissionsObject, PersonnelAttachmentObject, ProposalAttachmentObject, ProposalDevelopmentObject, ProposalLogObject, ProposalQuestionsObject, RoleAssigneeObject, RoleObject, S2SQuestionnaireObject, SpecialReviewObject, SubawardBudgetObject, UserObject
- Defined in:
- lib/kuality-coeus/data_objects/navigation.rb
Instance Method Summary collapse
- #doc_search ⇒ Object
-
#fill_out(page, *fields) ⇒ Object
(also: #fill_in)
Use in the #create method of your data objects for filling out fields.
-
#fill_out_item(name, page, *fields) ⇒ Object
Same as the above method, but used with methods that take a parameter to identify the target element…
- #on_document?(doc_header) ⇒ Boolean
- #on_page?(element) ⇒ Boolean
- #open_document(doc_header) ⇒ Object
- #window_cleanup ⇒ Object
Methods included from Utilities
#get, #make_role, #make_user, #random_percentage, #set, #snake_case
Instance Method Details
#doc_search ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/kuality-coeus/data_objects/navigation.rb', line 17 def doc_search visit DocumentSearch do |search| search.close_parents search.document_id.set @document_id search.search search.open_doc @document_id end end |
#fill_out(page, *fields) ⇒ Object Also known as: fill_in
Use in the #create method of your data objects for filling out fields. This method eliminates the need to write repetitive lines of code, with one line for every field needing to be filled in.
Requirement: The field method name and the class instance variable must be the same!
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/kuality-coeus/data_objects/navigation.rb', line 54 def fill_out(page, *fields) methods={ 'Watir::TextField' => lambda{|p, f| p.send(f).fit(get f)}, 'Watir::Select' => lambda{|p, f| p.send(f).pick!(get f)}, 'Watir::Radio' => lambda{|p, f| p.send(f, get(f)) unless get(f)==nil }, 'Watir::CheckBox' => lambda{|p, f| p.send(f).fit(get f) } } fields.shuffle.each do |field| # TODO: Someday see if there's a way to fix things so this rescue isn't necessary... # It's here because the radio button "element" definitions are *actions* that # require a parameter, so just sending the method to the page # is not going to work. begin key = page.send(field).class.to_s rescue NoMethodError key = 'Watir::Radio' end methods[key].call(page, field) end end |
#fill_out_item(name, page, *fields) ⇒ Object
Same as the above method, but used with methods that take a parameter to identify the target element…
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/kuality-coeus/data_objects/navigation.rb', line 78 def fill_out_item(name, page, *fields) methods={ 'Watir::TextField' => lambda{|n, p, f| p.send(f, n).fit(get f)}, 'Watir::Select' => lambda{|n, p, f| p.send(f, n).pick!(get f)}, 'Watir::Radio' => lambda{|n, p, f| p.send(f, n, get(f)) unless get(f)==nil }, 'Watir::CheckBox' => lambda{|n, p, f| p.send(f, n).fit(get f) } } fields.shuffle.each do |field| # TODO: Someday see if there's a way to fix things so this rescue isn't necessary... # It's here because the radio button "element" definitions are *actions* that # require a parameter, so just sending the method to the page # is not going to work. begin key = page.send(field, name).class.to_s rescue NoMethodError key = 'Watir::Radio' end methods[key].call(name, page, field) end end |
#on_document?(doc_header) ⇒ Boolean
9 10 11 12 13 14 15 |
# File 'lib/kuality-coeus/data_objects/navigation.rb', line 9 def on_document?(doc_header) begin on(DocumentHeader).document_id==@document_id && @browser.frm.div(id: 'headerarea').h1.text==doc_header rescue Watir::Exception::UnknownObjectException, Selenium::WebDriver::Error::StaleElementReferenceError false end end |
#on_page?(element) ⇒ Boolean
26 27 28 29 30 31 32 |
# File 'lib/kuality-coeus/data_objects/navigation.rb', line 26 def on_page? element begin element.exist? rescue Selenium::WebDriver::Error::StaleElementReferenceError false end end |
#open_document(doc_header) ⇒ Object
5 6 7 |
# File 'lib/kuality-coeus/data_objects/navigation.rb', line 5 def open_document doc_header doc_search unless on_document?(doc_header) end |
#window_cleanup ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/kuality-coeus/data_objects/navigation.rb', line 34 def window_cleanup on BasePage do |page| if page.windows.size > 1 && page.portal_window.exists? page.return_to_portal page.close_children elsif page.windows.size > 1 page.use_new_tab page.close_parents end end end |