6 class IssuesPage < Page
7 def initialize(driver, base_url, project)
8 super(driver, base_url, project)
10 #redmine-2.3: controller-issues action-index
11 #redmine-2.6: project-projectname controller-issues action-index
12 find_element :css, "body[class~='controller-issues'][class~='action-index']"
15 def self.open(driver, base_url, project)
16 driver.get "#{base_url}/projects/#{project}/issues/"
17 IssuesPage.new driver, base_url, project
21 issue_elements = find_elements(:css, "tr.issue")
22 issue_ids = issue_elements.map do |e|
23 #p "find:" + e.attribute("id")
24 /issue-(\d+)/ =~ e.attribute("id")
31 IssueNewPage.open @driver, @base_url, @project
34 def open_context(issue_id)
37 element = find_element(:css, "#issue-#{issue_id} > td.subject")
38 action.move_to(element).context_click(element).perform
40 QuickEditPage.new @driver, @base_url, @project, self
43 def find_quick_edit_menu_for_core_field(issue_id, attribute_name)
44 menu_selector = build_menu_selector_for_core_field(attribute_name)
48 menu_element = find_element(:id, "quick_edit_context")
49 menu_item_element = find_element(:css, menu_selector)
53 def find_quick_edit_menu_for_custom_field(issue_id, custom_field_id)
54 menu_selector = build_menu_selector_for_custom_field(custom_field_id)
58 menu_element = find_element(:id, "quick_edit_context")
59 menu_item_element = find_element(:css, menu_selector)
63 def quick_edit(issue_id, menu_selector, new_value)
66 menu_element = find_element(:id, "quick_edit_context")
67 menu_item_element = find_element(:css, menu_selector)
68 action.move_to(menu_element).click(menu_item_element).perform
70 if new_value.is_a?(Hash)
71 if new_value[:value] == :none
72 click :css, '#quick_edit_input_dialog #clear'
74 input_text :id, "new_value", new_value[:value]
76 input_text :id, "notes_for_edit", new_value[:notes][:text] unless new_value[:notes].nil?
77 click :id, "issue_private_notes_for_edit" if new_value[:notes][:is_private]
79 input_text :id, "new_value", new_value
82 buttons = find_elements(:css, "button > span")
83 submit_button = buttons.select {|button| button.text =~ /Submit/}
84 submit_button.first.click
87 def quick_edit_clear(issue_id, menu_selector)
90 menu_element = find_element(:id, "quick_edit_context")
91 menu_item_element = find_element(:css, menu_selector)
92 action.move_to(menu_element).click(menu_item_element).perform
94 find_element(:css, '#quick_edit_input_dialog #clear').click
96 buttons = find_elements(:css, "button > span")
97 submit_button = buttons.select {|button| button.text =~ /Submit/}
98 submit_button.first.click
101 def quick_edit_for_core_field(issue_id, attribute_name, new_value, desire_alerting = false)
102 menu_selector = "#quick_edit_context_#{attribute_name} > a"
104 quick_edit(issue_id, menu_selector, new_value)
106 self.class.open @driver, @base_url, @project unless desire_alerting
109 def quick_edit_clear_for_core_field(issue_id, attribute_name)
110 menu_selector = build_menu_selector_for_core_field(attribute_name)
112 quick_edit_clear(issue_id, menu_selector)
114 self.class.open @driver, @base_url, @project
117 def quick_edit_clear_for_custom_field(issue_id, custom_field_id)
118 menu_selector = build_menu_selector_for_custom_field(custom_field_id)
120 quick_edit_clear(issue_id, menu_selector)
122 self.class.open @driver, @base_url, @project
125 def build_menu_selector_for_core_field(attribute_name)
126 "#quick_edit_context_#{attribute_name} > a"
129 def build_menu_selector_for_custom_field(custom_field_id)
130 "#quick_edit_context_custom_field_values_#{custom_field_id} > a"
133 def quick_edit_for_custom_field(issue_id, custom_field_id, new_value, desire_alerting = false)
134 menu_selector = build_menu_selector_for_custom_field(custom_field_id)
136 open_context issue_id
138 menu_element = find_element(:id, "quick_edit_context")
139 menu_item_element = find_element(:css, menu_selector)
141 action.move_to(menu_element).click(menu_item_element).perform
143 input_text :id, "new_value", new_value
145 buttons = find_elements(:css, "button > span")
146 submit_button = buttons.select {|button| button.text =~ /Submit/}
147 submit_button.first.click
149 self.class.open @driver, @base_url, @project unless desire_alerting
152 def cancel_quick_edit
153 button_elements = find_elements(:css, 'span.ui-button-text')
154 cancel_button = button_elements.select do |button_element|
155 button_element.text == 'Cancel'
157 cancel_button.first.click