Class: OLE_QA::Framework::OLELS::Editor

Inherits:
Page show all
Defined in:
lib/olels/common/editor.rb

Overview

This represents the base object for the Describe Editor It generates elements common to all three editor screens:

  • Bibliographic Editor

  • Instance Editor (for Holdings)

  • Item Editor

Direct Known Subclasses

Bib_Editor, Instance_Editor, Item_Editor

Instance Attribute Summary

Attributes inherited from Page

#lines, #url, #wait_on

Attributes inherited from Common_Object

#elements, #functions, #ole

Instance Method Summary collapse

Methods inherited from Page

#lookup, #lookup_url, #open, #set_line, #wait_for_element, #wait_for_elements, #wait_for_page_to_load

Methods included from Helpers

#browser, #load_yml, #set_element, #set_function

Constructor Details

#initialize(ole_session) ⇒ Editor

The URL for this Page object is the universal Describe Editor URL in OLELS. When the Editor is opened via URL, it will start on the MARC Bibliographic Editor screen.

NB: The URL of the newly-opened editor instance will differ from the URL with which the screen was opened, so do not rely on URL equivalence tests to verify whether or not the Editor has been opened correctly.



35
36
37
38
39
# File 'lib/olels/common/editor.rb', line 35

def initialize(ole_session)
  editor_url =  ole_session.url + 'portal.do?channelTitle=Editor&channelUrl='
  editor_url += ole_session.url + 'ole-kr-krad/editorcontroller?viewId=EditorView&methodToCall=load&docCategory=work&docType=bibliographic&docFormat=marc&editable=true'
  super(ole_session, editor_url)
end

Instance Method Details

#set_elementsObject

Note:

“Return to Search” buttons will not appear when Editors are not invoked via Describe Workbench, despite their commonality.

Set elements common to all Editor screens.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/olels/common/editor.rb', line 44

def set_elements
  super
  element(:message)                             {b.li(:class => 'uif-infoMessageItem')}
  element(:messages)                            {b.lis(:class => 'uif-infoMessageItem')}
  element(:message_header)                      {b.h3(:class => 'uif-pageValidationHeader')}
  element(:submit_button)                       {b.button(:id => "submitEditor")}
  element(:cancel_button)                       {b.button(:id => "cancelEditor")}
  element(:close_button)                        {b.button(:id => "closeEditor")}
  element(:return_to_search_button)             {b.button(:id => "returnToSearch_button")}
  # Navigation Area Elements
  element(:delete_bib_button)                   {b.button(:title => 'Delete Bib')}
  element(:add_instance_button)                 {b.button(:title => 'Add Instance')}
  element(:add_einstance_button)                {b.button(:title => 'Add EInstance')}
  # @note Vakata Context Menu items are only present on the screen after the containing menu header has been right-clicked.
  element(:delete_instance_button)              {b.div(:id => 'vakata-contextmenu').ul.li(:index => 0).a(:rel => "Delete")}
  element(:add_item_button)                     {b.button(:title => 'Add Item')}
  element(:delete_item_button)                  {b.div(:id => 'vakata-contextmenu').ul.li(:index => 0).a(:rel => 'Delete')}
end

#set_functionsObject

Define commonly-used functions on Editor page objects.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/olels/common/editor.rb', line 64

def set_functions
  super
  # Click the submit button, wait until a message appears, and return the message text.
  function(:save_record)                        {submit_button.click ; message.wait_until_present ; message.text.strip}
  # Links for Holdings and Item Records - Pass a human-readable (1-based) variable to determine which instance of each link should be used.
  #   e.g., holdings_link(1) will return the first holdings link, holdings_link(2) will return the second.
  function(:holdings_link)                      {|which = 1| b.span(:xpath => "//div[@id='holdingsItemTree_tree']/ul[@class='jstree-no-icons']/li[#{which}]/a/span[@class='uif-message']")}
  function(:holdings_icon)                      {|which = 1| b.ins(:xpath => "//div[@id='holdingsItemTree_tree']/ul[@class='jstree-no-icons']/li[#{which}]/ins")}
  # This function takes two arguments - the first is the holdings element to which it belongs, and the second is its position.
  #   e.g., item_link(1,1) will return the first item under the first holdings link, item_link(2,2) will return the second item under the second holdings link.
  function(:item_link)                          {|which_holdings = 1, which_item = 1| b.a(:xpath => "//div[@id='holdingsItemTree_tree']/ul[@class='jstree-no-icons']/li[#{which_holdings}]/ul/li[#{which_item}]/a")}
  # Return the number of messages found in the .message_header text.
  #   - If .message_header is not present, a "0" will be returned.
  function(:message_count)                       { if message_header.present? then message_header.text.match(/\d(?=\smessage)/).to_s else "0" end}
end