6 class QuickEditPage < Page
7 def initialize(driver, base_url, project, before_page)
8 super(driver, base_url, project)
10 @before_page = before_page
12 find_element :id, "quick_edit_context"
15 def view_menu_item(issue_id, menu_selector)
16 menu_element = find_element(:id, "quick_edit_context")
17 menu_item_element = find_element(:css, menu_selector)
18 action.move_to(menu_element).perform
20 find_element(:css, menu_selector)
23 def update_field(issue_id, menu_selector, new_value, desire_alerting = false)
24 menu_element = find_element(:id, "quick_edit_context")
25 menu_item_element = find_element(:css, menu_selector)
26 action.move_to(menu_element).click(menu_item_element).perform
28 if new_value.is_a?(Hash)
29 input_text :id, "new_value", new_value[:value]
30 input_text :id, "notes_for_edit", new_value[:notes][:text] unless new_value[:notes].nil?
31 click :id, "issue_private_notes_for_edit" if new_value[:notes][:is_private]
33 input_text :id, "new_value", new_value
36 buttons = find_elements(:css, "button > span")
37 submit_button = buttons.select {|button| button.text =~ /Submit/}
38 submit_button.first.click
40 @before_page.class.open @driver, @base_url, @project unless desire_alerting
43 def clear_field(issue_id, menu_selector)
44 menu_element = find_element(:id, "quick_edit_context")
45 menu_item_element = find_element(:css, menu_selector)
46 action.move_to(menu_element).click(menu_item_element).perform
48 find_element(:css, '#quick_edit_input_dialog #clear').click
50 buttons = find_elements(:css, "button > span")
51 submit_button = buttons.select {|button| button.text =~ /Submit/}
52 submit_button.first.click
54 @before_page.class.open @driver, @base_url, @project
57 def preview_replace(issue_id, menu_selector, find_value, replace_value, match_case, desire_alerting = false)
58 menu_element = find_element(:id, "quick_edit_context")
59 menu_item_element = find_element(:css, menu_selector)
60 action.move_to(menu_element).click(menu_item_element).perform
62 click :id, :replace_switcher
64 input_text :id, :find, find_value
65 input_text :id, :replace, replace_value
66 click :id, :match_case if match_case
68 buttons = find_elements(:css, "button > span")
69 submit_button = buttons.select {|button| button.text =~ /Preview/}
70 submit_button.first.click
72 @before_page.class.open @driver, @base_url, @project unless desire_alerting
75 def get_replace_preview()
76 rows = find_elements(:css, "preview_area tbody tr")
78 previews = rows.map do |row|
79 id = row.find_element(:class, ".id").text
80 old = row.find_element(:class, ".old").text
81 new = row.find_element(:class, ".new").text
82 { :id => id, :old => old, :new => new }
86 def replace(issue_id, menu_selector, find_value, replace_value, match_case, desire_alerting = false)
87 menu_element = find_element(:id, "quick_edit_context")
88 menu_item_element = find_element(:css, menu_selector)
89 action.move_to(menu_element).click(menu_item_element).perform
91 click :id, :replace_switcher
93 if find_value.is_a?(Hash)
94 input_text :id, :find, find_value[:find]
95 input_text :css, "#quick_edit_input_dialog #replace", find_value[:replace]
96 click :id, :match_case if find_value[:match_case]
98 input_text :id, "notes_for_replace", find_value[:notes][:text] unless find_value[:notes].nil?
99 click :id, "issue_private_notes_for_replace" if find_value[:notes][:is_private]
101 input_text :id, :find, find_value
102 input_text :css, "#quick_edit_input_dialog #replace", replace_value
103 click :id, :match_case if match_case
106 buttons = find_elements(:css, "button > span")
107 submit_button = buttons.select {|button| button.text =~ /Submit/}
108 submit_button.first.click
110 alert.accept unless desire_alerting
112 @before_page.class.open @driver, @base_url, @project unless desire_alerting
115 def cancel_quick_edit
116 button_elements = find_elements(:css, 'span.ui-button-text')
117 cancel_buttons = button_elements.select do |button_element|
118 button_element.text == 'Cancel'
120 cancel_button = cancel_buttons.first
123 # new Selenium::WebDriver::Wait.new().until {
124 # !cancel_button.displayed?
128 def menu_selector(attribute_name, custom_field_id=nil)
129 if :custom_field == attribute_name.to_sym
130 "#quick_edit_context_custom_field_values_#{custom_field_id} > a"
132 "#quick_edit_context_#{attribute_name} > a"