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 input_text :id, "new_value", new_value
30 buttons = find_elements(:css, "button > span")
31 submit_button = buttons.select {|button| button.text =~ /Submit/}
32 submit_button.first.click
34 @before_page.class.open @driver, @base_url, @project unless desire_alerting
37 def clear_field(issue_id, menu_selector)
38 menu_element = find_element(:id, "quick_edit_context")
39 menu_item_element = find_element(:css, menu_selector)
40 action.move_to(menu_element).click(menu_item_element).perform
42 find_element(:css, '#quick_edit_input_dialog #clear').click
44 buttons = find_elements(:css, "button > span")
45 submit_button = buttons.select {|button| button.text =~ /Submit/}
46 submit_button.first.click
48 @before_page.class.open @driver, @base_url, @project
51 def preview_replace(issue_id, menu_selector, find_value, replace_value, desire_alerting = false)
52 menu_element = find_element(:id, "quick_edit_context")
53 menu_item_element = find_element(:css, menu_selector)
54 action.move_to(menu_element).click(menu_item_element).perform
56 click :id, :replace_switcher
58 input_text :id, :find, find_value
59 input_text :id, :replace, replace_value
61 buttons = find_elements(:css, "button > span")
62 submit_button = buttons.select {|button| button.text =~ /Preview/}
63 submit_button.first.click
65 @before_page.class.open @driver, @base_url, @project unless desire_alerting
68 def get_replace_preview()
69 rows = find_elements(:css, "preview_area tbody tr")
71 previews = rows.map do |row|
72 id = row.find_element(:class, ".id").text
73 old = row.find_element(:class, ".old").text
74 new = row.find_element(:class, ".new").text
75 { :id => id, :old => old, :new => new }
79 def replace(issue_id, menu_selector, find_value, replace_value, desire_alerting = false)
80 menu_element = find_element(:id, "quick_edit_context")
81 menu_item_element = find_element(:css, menu_selector)
82 action.move_to(menu_element).click(menu_item_element).perform
84 click :id, :replace_switcher
86 input_text :id, :find, find_value
87 input_text :css, "#quick_edit_input_dialog #replace", replace_value
89 buttons = find_elements(:css, "button > span")
90 submit_button = buttons.select {|button| button.text =~ /Submit/}
91 submit_button.first.click
93 @before_page.class.open @driver, @base_url, @project unless desire_alerting
97 button_elements = find_elements(:css, 'span.ui-button-text')
98 cancel_buttons = button_elements.select do |button_element|
99 button_element.text == 'Cancel'
101 cancel_button = cancel_buttons.first
104 # new Selenium::WebDriver::Wait.new().until {
105 # !cancel_button.displayed?
109 def menu_selector(attribute_name, custom_field_id=nil)
110 if :custom_field == attribute_name.to_sym
111 "#quick_edit_context_custom_field_values_#{custom_field_id} > a"
113 "#quick_edit_context_#{attribute_name} > a"