Added browser test helper to create and perfom Macros.

This commit is contained in:
Thorsten Eckel 2018-06-27 11:43:50 +02:00
parent a9239997ef
commit fb397822be

View file

@ -395,6 +395,13 @@ class TestCase < Test::Unit::TestCase
wait: 1, # wait 1 sec. wait: 1, # wait 1 sec.
) )
click(
browser: browser1,
xpath: '//a[contains(@class,".text-1")]',
fast: false, # do not wait
wait: 1, # wait 1 sec.
)
click( click(
browser: browser1, browser: browser1,
text: '.partial_link_text', text: '.partial_link_text',
@ -412,6 +419,9 @@ class TestCase < Test::Unit::TestCase
if params.include?(:css) if params.include?(:css)
param_key = :css param_key = :css
find_element_key = :css find_element_key = :css
elsif params.include?(:xpath)
param_key = :xpath
find_element_key = :xpath
else else
param_key = :text param_key = :text
find_element_key = :partial_link_text find_element_key = :partial_link_text
@ -447,6 +457,36 @@ class TestCase < Test::Unit::TestCase
sleep params[:wait] if params[:wait] sleep params[:wait] if params[:wait]
end end
=begin
perform_macro('Close & Tag as Spam')
# or
perform_macro(
name: 'Close & Tag as Spam',
browser: browser1,
)
=end
def perform_macro(params)
switch_window_focus(params)
log('perform_macro', params)
instance = params[:browser] || @browser
click(
browser: instance,
css: '.active.content .js-submitDropdown .js-openDropdownMacro'
)
click(
browser: instance,
xpath: "//div[contains(@class, 'content') and contains(@class, 'active')]//li[contains(@class, 'js-dropdownActionMacro') and contains(text(), '#{params[:name]}')]"
)
end
=begin =begin
scroll_to( scroll_to(
@ -3132,6 +3172,101 @@ wait untill text in selector disabppears
raise 'group creation failed' raise 'group creation failed'
end end
=begin
macro_create(
browser: browser1,
name: 'Emmanuel Macro',
ux_flow_next_up: 'Stay on tab', # possible: 'Stay on tab', 'Close tab', 'Advance to next ticket from overview'
actions: {
'Tags' => { # currently only 'Tags' is supported
operator: 'add',
value: 'spam',
}
}
)
=end
def macro_create(params)
switch_window_focus(params)
log('macro_create', params)
instance = params[:browser] || @browser
click(
browser: instance,
css: 'a[href="#manage"]',
mute_log: true,
)
click(
browser: instance,
css: '.sidebar a[href="#manage/macros"]',
mute_log: true,
)
click(
browser: instance,
css: '.page-header-meta > a[data-type="new"]'
)
sendkey(
browser: instance,
css: '.modal-body input[name="name"]',
value: params[:name]
)
params[:actions]&.each do |attribute, changes|
select(
browser: instance,
css: '.modal .ticket_perform_action .js-filterElement .js-attributeSelector select',
value: attribute,
mute_log: true,
)
next if attribute != 'Tags'
select(
browser: instance,
css: '.modal .ticket_perform_action .js-filterElement .js-operator select',
value: changes[:operator],
mute_log: true,
)
sendkey(
browser: instance,
css: '.modal .ticket_perform_action .js-filterElement .js-value .token-input',
value: changes[:value],
mute_log: true,
)
sendkey(
browser: instance,
value: :enter,
)
end
select(
browser: instance,
css: '.modal-body select[name="ux_flow_next_up"]',
value: params[:ux_flow_next_up]
)
click(
browser: instance,
css: '.modal-footer button[type="submit"]'
)
watch_for(
browser: instance,
css: 'body',
value: params[:name],
)
assert(true, 'macro created')
end
=begin =begin
role_create( role_create(