Keyboard shortcut improvements and browser tests.

This commit is contained in:
Martin Edenhofer 2016-02-25 13:45:46 +01:00
parent 17b171496c
commit 38317bbe8b
10 changed files with 452 additions and 215 deletions

View file

@ -205,7 +205,7 @@ class App.Controller extends Spine.Controller
# remember requested url # remember requested url
if !checkOnly if !checkOnly
location = window.location.hash location = window.location.hash
if location isnt '#login' && location isnt '#logout' if location isnt '#login' && location isnt '#logout' && location isnt '#keyboard_shortcuts'
@Config.set( 'requested_url', location) @Config.set( 'requested_url', location)
return false if checkOnly return false if checkOnly
@ -612,6 +612,7 @@ class App.ControllerContent extends App.Controller
@navShow() @navShow()
class App.ControllerModal extends App.Controller class App.ControllerModal extends App.Controller
authenticateRequired: false
backdrop: true backdrop: true
keyboard: true keyboard: true
large: false large: false
@ -638,6 +639,9 @@ class App.ControllerModal extends App.Controller
constructor: -> constructor: ->
super super
if @authenticateRequired
return if !@authenticate()
# rerender view, e. g. on langauge change # rerender view, e. g. on langauge change
@bind('ui:rerender', => @bind('ui:rerender', =>
@update() @update()

View file

@ -1,32 +1,6 @@
class Index extends App.ControllerModal class Index
large: true constructor: ->
head: 'Keyboard Shortcuts' new App.KeyboardShortcutModal()
buttonClose: true
buttonCancel: false
buttonSubmit: false
constructor: (params = {}) ->
delete params.el # do attache to body
super(params)
return if !@authenticate()
@bind('keyboard_shortcuts_close', @close)
content: ->
App.view('keyboard_shortcuts')(
areas: App.Config.get('keyboard_shortcuts')
)
onClosed: ->
window.history.go(-1)
onSubmit: ->
window.history.go(-1)
onCancel: ->
window.history.go(-1)
App.Config.set('keyboard_shortcuts', Index, 'Routes') App.Config.set('keyboard_shortcuts', Index, 'Routes')
App.Config.set('KeyboardShortcuts', { prio: 1700, parent: '#current_user', name: 'Keyboard Shortcuts', translate: true, target: '#keyboard_shortcuts', role: [ 'Admin', 'Agent' ] }, 'NavBarRight') App.Config.set('KeyboardShortcuts', { prio: 1700, parent: '#current_user', name: 'Keyboard Shortcuts', translate: true, target: '#keyboard_shortcuts', role: [ 'Admin', 'Agent' ] }, 'NavBarRight')

View file

@ -1,3 +1,24 @@
class App.KeyboardShortcutModal extends App.ControllerModal
authenticateRequired: true
large: true
head: 'Keyboard Shortcuts'
buttonClose: true
buttonCancel: false
buttonSubmit: false
constructor: ->
super
@bind('keyboard_shortcuts_close', @close)
content: ->
App.view('keyboard_shortcuts')(
areas: App.Config.get('keyboard_shortcuts')
)
exists: =>
return true if @el.parents('html').length > 0
false
class App.KeyboardShortcutWidget extends Spine.Module class App.KeyboardShortcutWidget extends Spine.Module
@include App.LogInclude @include App.LogInclude
@ -5,7 +26,6 @@ class App.KeyboardShortcutWidget extends Spine.Module
@observerKeys() @observerKeys()
observerKeys: => observerKeys: =>
#jQuery.hotkeys.options.filterInputAcceptingElements = false
navigationHotkeys = 'alt+ctrl' navigationHotkeys = 'alt+ctrl'
areas = App.Config.get('keyboard_shortcuts') areas = App.Config.get('keyboard_shortcuts')
for area in areas for area in areas
@ -37,59 +57,75 @@ App.Config.set(
key: 'd' key: 'd'
hotkeys: true hotkeys: true
description: 'Dashboard' description: 'Dashboard'
callback: -> callback: (e) ->
e.preventDefault()
App.Event.trigger('keyboard_shortcuts_close')
window.location.hash = '#dashboard' window.location.hash = '#dashboard'
} }
{ {
key: 'o' key: 'o'
hotkeys: true hotkeys: true
description: 'Overviews' description: 'Overviews'
callback: -> callback: (e) ->
e.preventDefault()
App.Event.trigger('keyboard_shortcuts_close')
window.location.hash = '#ticket/view' window.location.hash = '#ticket/view'
} }
{ {
key: 's' key: 's'
hotkeys: true hotkeys: true
description: 'Search' description: 'Search'
callback: -> callback: (e) ->
e.preventDefault()
App.Event.trigger('keyboard_shortcuts_close')
$('#global-search').focus() $('#global-search').focus()
} }
{ {
key: 'n' key: 'n'
hotkeys: true hotkeys: true
description: 'New Ticket' description: 'New Ticket'
callback: -> callback: (e) ->
e.preventDefault()
App.Event.trigger('keyboard_shortcuts_close')
window.location.hash = '#ticket/create' window.location.hash = '#ticket/create'
} }
{ {
key: 'e' key: 'e'
hotkeys: true hotkeys: true
description: 'Logout' description: 'Logout'
callback: -> callback: (e) ->
e.preventDefault()
App.Event.trigger('keyboard_shortcuts_close')
window.location.hash = '#logout' window.location.hash = '#logout'
} }
{ {
key: 'h' key: 'h'
hotkeys: true hotkeys: true
description: 'List of shortcuts' description: 'List of shortcuts'
callback: -> callback: (e) =>
if window.location.hash is '#keyboard_shortcuts' e.preventDefault()
App.Event.trigger('keyboard_shortcuts_close') if @dialog && @dialog.exists()
@dialog.close()
@dialog = false
return return
window.location.hash = '#keyboard_shortcuts' @dialog = new App.KeyboardShortcutModal()
} }
{ {
key: 'x' key: 'x'
hotkeys: true hotkeys: true
description: 'Close current tab' description: 'Close current tab'
callback: -> callback: (e) ->
e.preventDefault()
App.Event.trigger('keyboard_shortcuts_close')
$('#navigation .tasks .is-active .js-close').click() $('#navigation .tasks .is-active .js-close').click()
} }
{ {
key: 'tab' key: 'tab'
hotkeys: true hotkeys: true
description: 'Next in tab' description: 'Next in tab'
callback: -> callback: (e) ->
e.preventDefault()
App.Event.trigger('keyboard_shortcuts_close')
if $('#navigation .tasks .is-active').get(0) if $('#navigation .tasks .is-active').get(0)
if $('#navigation .tasks .is-active').next().get(0) if $('#navigation .tasks .is-active').next().get(0)
$('#navigation .tasks .is-active').next().find('div').first().click() $('#navigation .tasks .is-active').next().find('div').first().click()
@ -100,7 +136,9 @@ App.Config.set(
key: 'shift+tab' key: 'shift+tab'
hotkeys: true hotkeys: true
description: 'Previous tab' description: 'Previous tab'
callback: -> callback: (e) ->
e.preventDefault()
App.Event.trigger('keyboard_shortcuts_close')
if $('#navigation .tasks .is-active').get(0) if $('#navigation .tasks .is-active').get(0)
if $('#navigation .tasks .is-active').prev().get(0) if $('#navigation .tasks .is-active').prev().get(0)
$('#navigation .tasks .is-active').prev().find('div').first().click() $('#navigation .tasks .is-active').prev().find('div').first().click()
@ -111,7 +149,9 @@ App.Config.set(
key: 'return' key: 'return'
hotkeys: true hotkeys: true
description: 'Confirm/submit dialog' description: 'Confirm/submit dialog'
callback: -> callback: (e) ->
e.preventDefault()
App.Event.trigger('keyboard_shortcuts_close')
# check of primary modal exists # check of primary modal exists
dialog = $('body > div.modal') dialog = $('body > div.modal')
@ -185,14 +225,19 @@ App.Config.set(
key: 'm' key: 'm'
hotkeys: true hotkeys: true
description: 'Open note box' description: 'Open note box'
callback: -> callback: (e) ->
e.preventDefault()
App.Event.trigger('keyboard_shortcuts_close')
$('.active.content .editControls .js-articleTypes [data-value="note"]').click()
$('.active.content .article-new .articleNewEdit-body').first().focus() $('.active.content .article-new .articleNewEdit-body').first().focus()
} }
{ {
key: 'r' key: 'g'
hotkeys: true hotkeys: true
description: 'Reply to last article' description: 'Reply to last article'
callback: -> callback: (e) ->
e.preventDefault()
App.Event.trigger('keyboard_shortcuts_close')
lastArticleWithReply = $('.active.content .ticket-article .icon-reply').last() lastArticleWithReply = $('.active.content .ticket-article .icon-reply').last()
lastArticleWithReplyAll = lastArticleWithReply.parent().find('.icon-reply-all') lastArticleWithReplyAll = lastArticleWithReply.parent().find('.icon-reply-all')
if lastArticleWithReplyAll.get(0) if lastArticleWithReplyAll.get(0)
@ -200,18 +245,30 @@ App.Config.set(
return return
lastArticleWithReply.click() lastArticleWithReply.click()
} }
{
key: 'j'
hotkeys: true
description: 'Set article to internal/public'
callback: (e) ->
e.preventDefault()
App.Event.trigger('keyboard_shortcuts_close')
$('.active.content .editControls .js-selectInternalPublic').click()
}
#{ #{
# key: 'm' # key: 'm'
# hotkeys: true # hotkeys: true
# description: 'Open macro selection' # description: 'Open macro selection'
# callback: -> # callback: (e) ->
# e.preventDefault()
# window.location.hash = '#ticket/create' # window.location.hash = '#ticket/create'
#} #}
{ {
key: 'c' key: 'c'
hotkeys: true hotkeys: true
description: 'Update as closed' description: 'Update as closed'
callback: -> callback: (e) ->
e.preventDefault()
App.Event.trigger('keyboard_shortcuts_close')
return if !$('.active.content .edit').get(0) return if !$('.active.content .edit').get(0)
$('.active.content .edit [name="state_id"]').val(4) $('.active.content .edit [name="state_id"]').val(4)
$('.active.content .js-attributeBar .js-submit').first().click() $('.active.content .js-attributeBar .js-submit').first().click()

View file

@ -127,6 +127,12 @@
|| e.keyCode == 79 || e.keyCode == 79
|| e.keyCode == 87)) { || e.keyCode == 87)) {
e.preventDefault() e.preventDefault()
// disable rich text b/u/i
if ( _this.options.mode === 'textonly' ) {
return
}
if (e.keyCode == 66) { if (e.keyCode == 66) {
document.execCommand('Bold') document.execCommand('Bold')
} }
@ -234,15 +240,6 @@
document.execCommand('insertHTML', false, text) document.execCommand('insertHTML', false, text)
return true return true
}) })
// disable rich text b/u/i
if ( this.options.mode === 'textonly' ) {
this.$element.on('keydown', function (e) {
if ( _this.richTextKey(e) ) {
e.preventDefault()
}
})
}
} }
// check if key is allowed, even if length limit is reached // check if key is allowed, even if length limit is reached

View file

@ -121,9 +121,12 @@
textInputTypes: /textarea|input|select/i, textInputTypes: /textarea|input|select/i,
options: { options: {
filterInputAcceptingElements: true, //filterInputAcceptingElements: true,
filterTextInputs: true, //filterTextInputs: true,
filterContentEditable: true //filterContentEditable: true
filterInputAcceptingElements: false,
filterTextInputs: false,
filterContentEditable: false
} }
}; };

View file

@ -59,10 +59,10 @@ var originalShow = $.fn.popover.Constructor.prototype.show;
$.fn.popover.Constructor.prototype.show = function(){ $.fn.popover.Constructor.prototype.show = function(){
originalShow.call(this); originalShow.call(this);
var maxHeight = $(this.options.viewport.selector).height() - 2 * this.options.viewport.padding;
// improved error handling - no exeption if no $tip exists // improved error handling - no exeption if no $tip exists
if (!this.$tip) { if (!this.$tip) {
return return
} }
var maxHeight = $(this.options.viewport.selector).height() - 2 * this.options.viewport.padding;
this.$tip.find('.popover-body').css('maxHeight', maxHeight); this.$tip.find('.popover-body').css('maxHeight', maxHeight);
} }

View file

@ -21,7 +21,7 @@
<% end %> <% end %>
</div> </div>
</div> </div>
<div class="editControls-item is-hidden js-toggleVisibility"> <div class="editControls-item is-hidden js-toggleVisibility js-selectInternalPublic">
<div class="editControls-iconHolder"> <div class="editControls-iconHolder">
<div class="editControls-icon icon-internal" title="<%- @Ti("set to public") %>"> <div class="editControls-icon icon-internal" title="<%- @Ti("set to public") %>">
<%- @Icon('lock') %> <%- @Icon('lock') %>

View file

@ -9,6 +9,7 @@ if [ "$LEVEL" == '1' ]; then
rm test/browser/agent_organization_profile_test.rb rm test/browser/agent_organization_profile_test.rb
rm test/browser/agent_ticket_*.rb rm test/browser/agent_ticket_*.rb
rm test/browser/chat_test.rb rm test/browser/chat_test.rb
rm test/browser/keyboard_shortcuts_test.rb
rm test/browser/prefereces_test.rb rm test/browser/prefereces_test.rb
rm test/browser/setting_test.rb rm test/browser/setting_test.rb
@ -25,6 +26,7 @@ elif [ "$LEVEL" == '2' ]; then
rm test/browser/chat_test.rb rm test/browser/chat_test.rb
rm test/browser/customer_ticket_create_test.rb rm test/browser/customer_ticket_create_test.rb
rm test/browser/form_test.rb rm test/browser/form_test.rb
rm test/browser/keyboard_shortcuts_test.rb
rm test/browser/maintenance_*.rb rm test/browser/maintenance_*.rb
rm test/browser/manage_test.rb rm test/browser/manage_test.rb
rm test/browser/prefereces_test.rb rm test/browser/prefereces_test.rb

View file

@ -0,0 +1,163 @@
# encoding: utf-8
require 'browser_test_helper'
class KeyboardShortcutsTest < TestCase
def test_navigation
@browser = browser_instance
login(
username: 'master@example.com',
password: 'test',
url: browser_url,
)
tasks_close_all()
# show shortkeys
shortcut(key: 'h')
watch_for(
css: '.modal',
value: 'Keyboard Shortcuts',
timeout: 2,
)
# hide shortkeys
shortcut(key: 'h')
watch_for_disappear(
css: '.modal',
value: 'Keyboard Shortcuts',
timeout: 2,
)
# show shortkeys
shortcut(key: 'h')
watch_for(
css: '.modal',
value: 'Keyboard Shortcuts',
timeout: 2,
)
# go to overviews
shortcut(key: 'o')
watch_for(
css: '.active.content',
value: 'My assigned Tickets',
timeout: 2,
)
# go to dashboard
shortcut(key: 'd')
watch_for(
css: '.active.content',
value: 'My Stats',
timeout: 2,
)
# go to new ticket
shortcut(key: 'n')
watch_for(
css: '.active.content',
value: 'New Ticket',
timeout: 2,
)
# close again
shortcut(key: 'x')
watch_for_disappear(
css: '.active.content',
value: 'New Ticket',
timeout: 2,
)
ticket1 = ticket_create(
data: {
customer: 'nico',
group: 'Users',
title: 'Test Ticket for Shortcuts - ABC123',
body: 'Test Ticket Body for Shortcuts - ABC123',
},
)
sleep 5
# close again
shortcut(key: 'x')
watch_for_disappear(
css: '.active.content',
value: ticket1[:number],
timeout: 2,
)
# search it
shortcut(key: 's')
window_keys(value: ticket1[:number])
exists(css: '#navigation .search.open')
sleep 2
window_keys(value: :arrow_down)
window_keys(value: :enter)
watch_for(
css: '.active.content',
value: ticket1[:number],
timeout: 2,
)
exists_not(css: '#navigation .search.open')
# open ticket
shortcut(key: 's')
window_keys(value: ticket1[:number])
sleep 2
window_keys(value: :arrow_down)
window_keys(value: :enter)
# open new ticket
shortcut(key: 'n')
watch_for(
css: '.active.content',
value: 'New Ticket',
timeout: 2,
)
tab_count = @browser.find_elements(css: '#navigation .tasks .task').count
assert_equal(2, tab_count)
# tab is tab
shortcut(key: :tab)
watch_for(
css: '.active.content',
value: ticket1[:number],
timeout: 2,
)
shortcut(key: 'm')
shortcut(key: 'j')
window_keys(value: 'some note')
shortcut(key: :enter)
watch_for(
css: '.active.content .ticket-article',
value: 'some note',
timeout: 6,
)
exists(css: '.active.content .ticket-article .internal-border')
shortcut(key: 'g')
window_keys(value: 'some reply')
shortcut(key: :enter)
watch_for(
css: '.active.content .ticket-article',
value: 'some reply',
timeout: 6,
)
shortcut(key: 'c')
watch_for(
css: '.active.content .sidebar-content .edit',
value: 'closed',
timeout: 6,
)
shortcut(key: 'e')
watch_for(
css: 'body',
value: 'login',
timeout: 4,
)
end
end

View file

@ -138,7 +138,7 @@ class TestCase < Test::Unit::TestCase
instance.get(params[:url]) instance.get(params[:url])
end end
element = instance.find_elements({ css: '#login input[name="username"]' })[0] element = instance.find_elements(css: '#login input[name="username"]')[0]
if !element if !element
if params[:auto_wizard] if params[:auto_wizard]
@ -150,7 +150,7 @@ class TestCase < Test::Unit::TestCase
) )
location( url: "#{browser_url}/#getting_started/auto_wizard" ) location( url: "#{browser_url}/#getting_started/auto_wizard" )
sleep 10 sleep 10
login = instance.find_elements({ css: '.user-menu .user a' })[0].attribute('title') login = instance.find_elements(css: '.user-menu .user a')[0].attribute('title')
if login != params[:username] if login != params[:username]
screenshot(browser: instance, comment: 'auto wizard login failed') screenshot(browser: instance, comment: 'auto wizard login failed')
fail 'auto wizard login failed' fail 'auto wizard login failed'
@ -173,17 +173,17 @@ class TestCase < Test::Unit::TestCase
element.clear element.clear
element.send_keys(params[:username]) element.send_keys(params[:username])
element = instance.find_elements({ css: '#login input[name="password"]' })[0] element = instance.find_elements(css: '#login input[name="password"]')[0]
element.clear element.clear
element.send_keys(params[:password]) element.send_keys(params[:password])
if params[:remember_me] if params[:remember_me]
instance.find_elements({ css: '#login .checkbox-replacement' })[0].click instance.find_elements(css: '#login .checkbox-replacement')[0].click
end end
instance.find_elements({ css: '#login button' })[0].click instance.find_elements(css: '#login button')[0].click
sleep 5 sleep 5
login = instance.find_elements({ css: '.user-menu .user a' })[0].attribute('title') login = instance.find_elements(css: '.user-menu .user a')[0].attribute('title')
if login != params[:username] if login != params[:username]
screenshot(browser: instance, comment: 'login_failed') screenshot(browser: instance, comment: 'login_failed')
fail 'login failed' fail 'login failed'
@ -213,12 +213,12 @@ class TestCase < Test::Unit::TestCase
instance = params[:browser] || @browser instance = params[:browser] || @browser
instance.find_elements({ css: 'a[href="#current_user"]' })[0].click instance.find_elements(css: 'a[href="#current_user"]')[0].click
sleep 0.1 sleep 0.1
instance.find_elements({ css: 'a[href="#logout"]' })[0].click instance.find_elements(css: 'a[href="#logout"]')[0].click
(1..6).each { (1..6).each {
sleep 1 sleep 1
login = instance.find_elements({ css: '#login' })[0] login = instance.find_elements(css: '#login')[0]
next if !login next if !login
screenshot(browser: instance, comment: 'logout_ok') screenshot(browser: instance, comment: 'logout_ok')
@ -244,7 +244,7 @@ class TestCase < Test::Unit::TestCase
instance = params[:browser] || @browser instance = params[:browser] || @browser
clues = instance.find_elements({ css: '.js-modal--clue .js-close' })[0] clues = instance.find_elements(css: '.js-modal--clue .js-close')[0]
if !params[:optional] && !clues if !params[:optional] && !clues
screenshot(browser: instance, comment: 'no_clues') screenshot(browser: instance, comment: 'no_clues')
fail 'Unable to closes clues, no clues found!' fail 'Unable to closes clues, no clues found!'
@ -316,7 +316,7 @@ class TestCase < Test::Unit::TestCase
instance.navigate.refresh instance.navigate.refresh
# check if reload was successfull # check if reload was successfull
if !instance.find_elements({ css: 'body' })[0] || instance.find_elements({ css: 'body' })[0].text =~ /unavailable or too busy/i if !instance.find_elements(css: 'body')[0] || instance.find_elements(css: 'body')[0].text =~ /unavailable or too busy/i
instance.navigate.refresh instance.navigate.refresh
end end
screenshot(browser: instance, comment: 'reload_after') screenshot(browser: instance, comment: 'reload_after')
@ -347,7 +347,7 @@ class TestCase < Test::Unit::TestCase
instance = params[:browser] || @browser instance = params[:browser] || @browser
if params[:css] if params[:css]
element = instance.find_elements({ css: params[:css] })[0] element = instance.find_elements(css: params[:css])[0]
#instance.mouse.move_to(element) #instance.mouse.move_to(element)
#sleep 0.2 #sleep 0.2
element.click element.click
@ -358,7 +358,7 @@ class TestCase < Test::Unit::TestCase
# sleep 0.2 # sleep 0.2
#end #end
else else
instance.find_elements({ partial_link_text: params[:text] })[0].click instance.find_elements(partial_link_text: params[:text])[0].click
end end
sleep 0.4 if !params[:fast] sleep 0.4 if !params[:fast]
sleep params[:wait] if params[:wait] sleep params[:wait] if params[:wait]
@ -427,7 +427,7 @@ class TestCase < Test::Unit::TestCase
log('exists', params) log('exists', params)
instance = params[:browser] || @browser instance = params[:browser] || @browser
if !instance.find_elements({ css: params[:css] } )[0] if !instance.find_elements(css: params[:css])[0]
screenshot(browser: instance, comment: 'exists_failed') screenshot(browser: instance, comment: 'exists_failed')
fail "#{params[:css]} dosn't exist, but should" fail "#{params[:css]} dosn't exist, but should"
end end
@ -448,7 +448,7 @@ class TestCase < Test::Unit::TestCase
log('exists_not', params) log('exists_not', params)
instance = params[:browser] || @browser instance = params[:browser] || @browser
if instance.find_elements({ css: params[:css] } )[0] if instance.find_elements(css: params[:css])[0]
screenshot(browser: instance, comment: 'exists_not_failed') screenshot(browser: instance, comment: 'exists_not_failed')
fail "#{params[:css]} exists but should not" fail "#{params[:css]} exists but should not"
end end
@ -475,7 +475,7 @@ class TestCase < Test::Unit::TestCase
instance = params[:browser] || @browser instance = params[:browser] || @browser
element = instance.find_elements({ css: params[:css] })[0] element = instance.find_elements(css: params[:css])[0]
if !params[:no_click] if !params[:no_click]
element.click element.click
end end
@ -515,9 +515,9 @@ class TestCase < Test::Unit::TestCase
instance = params[:browser] || @browser instance = params[:browser] || @browser
# searchable select # searchable select
element = instance.find_elements({ css: "#{params[:css]}.js-shadow" })[0] element = instance.find_elements(css: "#{params[:css]}.js-shadow")[0]
if element if element
element = instance.find_elements({ css: "#{params[:css]}.js-shadow + .js-input" })[0] element = instance.find_elements(css: "#{params[:css]}.js-shadow + .js-input")[0]
element.click element.click
element.clear element.clear
sleep 1 sleep 1
@ -530,13 +530,13 @@ class TestCase < Test::Unit::TestCase
# native select # native select
begin begin
element = instance.find_elements({ css: params[:css] })[0] element = instance.find_elements(css: params[:css])[0]
dropdown = Selenium::WebDriver::Support::Select.new(element) dropdown = Selenium::WebDriver::Support::Select.new(element)
dropdown.select_by(:text, params[:value]) dropdown.select_by(:text, params[:value])
puts "select - #{params.inspect}" puts "select - #{params.inspect}"
rescue rescue
# just try again # just try again
element = instance.find_elements({ css: params[:css] })[0] element = instance.find_elements(css: params[:css])[0]
dropdown = Selenium::WebDriver::Support::Select.new(element) dropdown = Selenium::WebDriver::Support::Select.new(element)
dropdown.select_by(:text, params[:value]) dropdown.select_by(:text, params[:value])
puts "select2 - #{params.inspect}" puts "select2 - #{params.inspect}"
@ -559,14 +559,14 @@ class TestCase < Test::Unit::TestCase
instance = params[:browser] || @browser instance = params[:browser] || @browser
element = instance.find_elements({ css: "#{params[:css]} input[type=checkbox]" })[0] element = instance.find_elements(css: "#{params[:css]} input[type=checkbox]")[0]
checked = element.attribute('checked') checked = element.attribute('checked')
if !checked if !checked
if params[:type] == 'on' if params[:type] == 'on'
instance.find_elements({ css: "#{params[:css]} label" })[0].click instance.find_elements(css: "#{params[:css]} label")[0].click
end end
elsif params[:type] == 'off' elsif params[:type] == 'off'
instance.find_elements({ css: "#{params[:css]} label" })[0].click instance.find_elements(css: "#{params[:css]} label")[0].click
end end
end end
@ -585,7 +585,7 @@ class TestCase < Test::Unit::TestCase
instance = params[:browser] || @browser instance = params[:browser] || @browser
element = instance.find_elements({ css: params[:css] })[0] element = instance.find_elements(css: params[:css])[0]
checked = element.attribute('checked') checked = element.attribute('checked')
element.click if !checked element.click if !checked
end end
@ -605,7 +605,7 @@ class TestCase < Test::Unit::TestCase
instance = params[:browser] || @browser instance = params[:browser] || @browser
element = instance.find_elements({ css: params[:css] })[0] element = instance.find_elements(css: params[:css])[0]
checked = element.attribute('checked') checked = element.attribute('checked')
element.click if checked element.click if checked
end end
@ -657,7 +657,7 @@ class TestCase < Test::Unit::TestCase
log('match', params) log('match', params)
instance = params[:browser] || @browser instance = params[:browser] || @browser
element = instance.find_elements({ css: params[:css] })[0] element = instance.find_elements(css: params[:css])[0]
if params[:css] =~ /select/ if params[:css] =~ /select/
dropdown = Selenium::WebDriver::Support::Select.new(element) dropdown = Selenium::WebDriver::Support::Select.new(element)
@ -763,8 +763,8 @@ class TestCase < Test::Unit::TestCase
instance = params[:browser] || @browser instance = params[:browser] || @browser
if params[:type] if params[:type]
instance.find_elements({ css: '.content.active .js-secondaryActionButtonLabel' })[0].click instance.find_elements(css: '.content.active .js-secondaryActionButtonLabel')[0].click
instance.find_elements({ css: ".content.active .js-secondaryActionLabel[data-type=#{params[:type]}]" })[0].click instance.find_elements(css: ".content.active .js-secondaryActionLabel[data-type=#{params[:type]}]")[0].click
return return
end end
fail "Unknown params for task_type: #{params.inspect}" fail "Unknown params for task_type: #{params.inspect}"
@ -874,7 +874,7 @@ class TestCase < Test::Unit::TestCase
# verify title # verify title
if data[:title] if data[:title]
title = instance.find_elements({ css: '.tasks .is-active' })[0].text.strip title = instance.find_elements(css: '.tasks .is-active')[0].text.strip
if title =~ /#{data[:title]}/i if title =~ /#{data[:title]}/i
assert(true, "matching '#{data[:title]}' in title '#{title}'") assert(true, "matching '#{data[:title]}' in title '#{title}'")
else else
@ -884,8 +884,8 @@ class TestCase < Test::Unit::TestCase
puts "tv #{params.inspect}" puts "tv #{params.inspect}"
# verify modified # verify modified
if data.key?(:modified) if data.key?(:modified)
exists = instance.find_elements({ css: '.tasks .is-active' })[0] exists = instance.find_elements(css: '.tasks .is-active')[0]
is_modified = instance.find_elements({ css: '.tasks .is-modified' })[0] is_modified = instance.find_elements(css: '.tasks .is-modified')[0]
puts "m #{data[:modified].inspect}" puts "m #{data[:modified].inspect}"
if exists if exists
puts ' exists' puts ' exists'
@ -938,7 +938,7 @@ class TestCase < Test::Unit::TestCase
instance = params[:browser] || @browser instance = params[:browser] || @browser
data = params[:data] data = params[:data]
element = instance.find_elements({ partial_link_text: data[:title] })[0] element = instance.find_elements(partial_link_text: data[:title])[0]
if !element if !element
screenshot(browser: instance, comment: 'open_task_failed') screenshot(browser: instance, comment: 'open_task_failed')
fail "no task with title '#{data[:title]}' found" fail "no task with title '#{data[:title]}' found"
@ -964,7 +964,7 @@ class TestCase < Test::Unit::TestCase
instance = params[:browser] || @browser instance = params[:browser] || @browser
params[:files].each {|file| params[:files].each {|file|
instance.find_elements({ css: params[:css] })[0].send_keys "#{Rails.root}/#{file}" instance.find_elements(css: params[:css])[0].send_keys "#{Rails.root}/#{file}"
} }
sleep 2 * params[:files].count sleep 2 * params[:files].count
end end
@ -994,7 +994,7 @@ class TestCase < Test::Unit::TestCase
loops = timeout.to_i * 2 loops = timeout.to_i * 2
text = '' text = ''
(1..loops).each { (1..loops).each {
element = instance.find_elements({ css: params[:css] })[0] element = instance.find_elements(css: params[:css])[0]
if element #&& element.displayed? if element #&& element.displayed?
begin begin
@ -1055,7 +1055,7 @@ wait untill text in selector disabppears
loops = timeout.to_i loops = timeout.to_i
text = '' text = ''
(1..loops).each { (1..loops).each {
element = instance.find_elements({ css: params[:css] })[0] element = instance.find_elements(css: params[:css])[0]
if !element #|| element.displayed? if !element #|| element.displayed?
assert(true, 'not found') assert(true, 'not found')
sleep 1 sleep 1
@ -1063,7 +1063,7 @@ wait untill text in selector disabppears
end end
if params[:value] if params[:value]
begin begin
text = instance.find_elements({ css: params[:css] })[0].text text = instance.find_elements(css: params[:css])[0].text
if text !~ /#{params[:value]}/i if text !~ /#{params[:value]}/i
assert(true, "not matching '#{params[:value]}' in text '#{text}'") assert(true, "not matching '#{params[:value]}' in text '#{text}'")
sleep 1 sleep 1
@ -1079,6 +1079,43 @@ wait untill text in selector disabppears
fail "#{params[:css]}) still exsists" fail "#{params[:css]}) still exsists"
end end
=begin
shortcut(
browser: browser1,
key: 'x',
)
=end
def shortcut(params = {})
switch_window_focus(params)
log('shortcut', params)
instance = params[:browser] || @browser
instance.action.key_down(:control)
.key_down(:alt)
.send_keys(params[:key])
.key_up(:alt)
.key_up(:control)
.perform
end
=begin
window_keys(
browser: browser1,
value: 'x',
)
=end
def window_keys(params = {})
switch_window_focus(params)
log('window_keys', params)
instance = params[:browser] || @browser
instance.action.send_keys(params[:value]).perform
end
=begin =begin
tasks_close_all( tasks_close_all(
@ -1097,17 +1134,17 @@ wait untill text in selector disabppears
(1..100).each do (1..100).each do
sleep 1 sleep 1
begin begin
if instance.find_elements({ css: '.navigation .tasks .task:first-child' })[0] if instance.find_elements(css: '.navigation .tasks .task:first-child')[0]
instance.mouse.move_to(instance.find_elements({ css: '.navigation .tasks .task:first-child' })[0]) instance.mouse.move_to(instance.find_elements(css: '.navigation .tasks .task:first-child')[0])
sleep 0.1 sleep 0.1
click_element = instance.find_elements({ css: '.navigation .tasks .task:first-child .js-close' })[0] click_element = instance.find_elements(css: '.navigation .tasks .task:first-child .js-close')[0]
if click_element if click_element
click_element.click click_element.click
# accept task close warning # accept task close warning
if params[:discard_changes] if params[:discard_changes]
sleep 1 sleep 1
instance.find_elements({ css: '.modal button.js-submit' })[0].click instance.find_elements(css: '.modal button.js-submit')[0].click
end end
end end
else else
@ -1137,7 +1174,7 @@ wait untill text in selector disabppears
instance = params[:browser] || @browser instance = params[:browser] || @browser
element = instance.find_elements({ css: params[:css] + ' input[name="customer_id_completion"]' })[0] element = instance.find_elements(css: params[:css] + ' input[name="customer_id_completion"]')[0]
element.click element.click
element.clear element.clear
@ -1151,7 +1188,7 @@ wait untill text in selector disabppears
element.send_keys(:arrow_down) element.send_keys(:arrow_down)
sleep 0.3 sleep 0.3
element.send_keys(:enter) element.send_keys(:enter)
#instance.find_elements({ css: params[:css] + ' .recipientList-entry.js-user.is-active' })[0].click #instance.find_elements(css: params[:css] + ' .recipientList-entry.js-user.is-active')[0].click
sleep 0.6 sleep 0.6
assert(true, 'ticket_customer_select') assert(true, 'ticket_customer_select')
end end
@ -1180,29 +1217,29 @@ wait untill text in selector disabppears
instance = params[:browser] || @browser instance = params[:browser] || @browser
data = params[:data] data = params[:data]
instance.find_elements({ css: 'a[href="#manage"]' })[0].click instance.find_elements(css: 'a[href="#manage"]')[0].click
instance.find_elements({ css: 'a[href="#manage/overviews"]' })[0].click instance.find_elements(css: 'a[href="#manage/overviews"]')[0].click
sleep 0.2 sleep 0.2
instance.find_elements({ css: '#content a[data-type="new"]' })[0].click instance.find_elements(css: '#content a[data-type="new"]')[0].click
sleep 2 sleep 2
if data[:name] if data[:name]
element = instance.find_elements({ css: '.modal input[name=name]' })[0] element = instance.find_elements(css: '.modal input[name=name]')[0]
element.clear element.clear
element.send_keys(data[:name]) element.send_keys(data[:name])
end end
if data[:role] if data[:role]
element = instance.find_elements({ css: '.modal select[name="role_id"]' })[0] element = instance.find_elements(css: '.modal select[name="role_id"]')[0]
dropdown = Selenium::WebDriver::Support::Select.new(element) dropdown = Selenium::WebDriver::Support::Select.new(element)
dropdown.select_by(:text, data[:role]) dropdown.select_by(:text, data[:role])
end end
if data[:selector] if data[:selector]
data[:selector].each {|key, value| data[:selector].each {|key, value|
element = instance.find_elements({ css: '.modal .ticket_selector .js-attributeSelector select' })[0] element = instance.find_elements(css: '.modal .ticket_selector .js-attributeSelector select')[0]
dropdown = Selenium::WebDriver::Support::Select.new(element) dropdown = Selenium::WebDriver::Support::Select.new(element)
dropdown.select_by(:text, key) dropdown.select_by(:text, key)
element = instance.find_elements({ css: '.modal .ticket_selector .js-value select' })[0] element = instance.find_elements(css: '.modal .ticket_selector .js-value select')[0]
dropdown = Selenium::WebDriver::Support::Select.new(element) dropdown = Selenium::WebDriver::Support::Select.new(element)
dropdown.deselect_all dropdown.deselect_all
dropdown.select_by(:text, value) dropdown.select_by(:text, value)
@ -1210,19 +1247,19 @@ wait untill text in selector disabppears
end end
if data[:prio] if data[:prio]
element = instance.find_elements({ css: '.modal input[name=prio]' })[0] element = instance.find_elements(css: '.modal input[name=prio]')[0]
element.clear element.clear
element.send_keys(data[:prio]) element.send_keys(data[:prio])
end end
if data['order::direction'] if data['order::direction']
element = instance.find_elements({ css: '.modal select[name="order::direction"]' })[0] element = instance.find_elements(css: '.modal select[name="order::direction"]')[0]
dropdown = Selenium::WebDriver::Support::Select.new(element) dropdown = Selenium::WebDriver::Support::Select.new(element)
dropdown.select_by(:text, data['order::direction']) dropdown.select_by(:text, data['order::direction'])
end end
instance.find_elements({ css: '.modal button.js-submit' })[0].click instance.find_elements(css: '.modal button.js-submit')[0].click
(1..12).each { (1..12).each {
element = instance.find_elements({ css: 'body' })[0] element = instance.find_elements(css: 'body')[0]
text = element.text text = element.text
if text =~ /#{Regexp.quote(data[:name])}/ if text =~ /#{Regexp.quote(data[:name])}/
assert(true, 'overview created') assert(true, 'overview created')
@ -1267,9 +1304,9 @@ wait untill text in selector disabppears
instance = params[:browser] || @browser instance = params[:browser] || @browser
data = params[:data] data = params[:data]
instance.find_elements({ css: 'a[href="#new"]' })[0].click instance.find_elements(css: 'a[href="#new"]')[0].click
instance.find_elements({ css: 'a[href="#ticket/create"]' })[0].click instance.find_elements(css: 'a[href="#ticket/create"]')[0].click
element = instance.find_elements({ css: '.active .newTicket' })[0] element = instance.find_elements(css: '.active .newTicket')[0]
if !element if !element
screenshot(browser: instance, comment: 'ticket_create_failed') screenshot(browser: instance, comment: 'ticket_create_failed')
fail 'no ticket create screen found!' fail 'no ticket create screen found!'
@ -1277,23 +1314,23 @@ wait untill text in selector disabppears
sleep 1 sleep 1
# check count of agents, should be only 1 / - selection on init screen # check count of agents, should be only 1 / - selection on init screen
count = instance.find_elements({ css: '.active .newTicket select[name="owner_id"] option' }).count count = instance.find_elements(css: '.active .newTicket select[name="owner_id"] option').count
assert_equal(1, count, 'check if owner selection is empty per default' ) assert_equal(1, count, 'check if owner selection is empty per default' )
if data[:group] if data[:group]
element = instance.find_elements({ css: '.active .newTicket select[name="group_id"]' })[0] element = instance.find_elements(css: '.active .newTicket select[name="group_id"]')[0]
dropdown = Selenium::WebDriver::Support::Select.new(element) dropdown = Selenium::WebDriver::Support::Select.new(element)
dropdown.select_by(:text, data[:group]) dropdown.select_by(:text, data[:group])
sleep 0.2 sleep 0.2
end end
if data[:priority] if data[:priority]
element = instance.find_elements({ css: '.active .newTicket select[name="priority_id"]' })[0] element = instance.find_elements(css: '.active .newTicket select[name="priority_id"]')[0]
dropdown = Selenium::WebDriver::Support::Select.new(element) dropdown = Selenium::WebDriver::Support::Select.new(element)
dropdown.select_by(:text, data[:priority]) dropdown.select_by(:text, data[:priority])
sleep 0.2 sleep 0.2
end end
if data[:title] if data[:title]
element = instance.find_elements({ css: '.active .newTicket input[name="title"]' })[0] element = instance.find_elements(css: '.active .newTicket input[name="title"]')[0]
element.clear element.clear
element.send_keys(data[:title]) element.send_keys(data[:title])
sleep 0.2 sleep 0.2
@ -1301,12 +1338,12 @@ wait untill text in selector disabppears
if data[:body] if data[:body]
#instance.execute_script('$(".active .newTicket div[data-name=body]").focus()') #instance.execute_script('$(".active .newTicket div[data-name=body]").focus()')
sleep 0.5 sleep 0.5
element = instance.find_elements({ css: '.active .newTicket div[data-name=body]' })[0] element = instance.find_elements(css: '.active .newTicket div[data-name=body]')[0]
element.clear element.clear
element.send_keys(data[:body]) element.send_keys(data[:body])
# it's not working stable via selenium, use js # it's not working stable via selenium, use js
value = instance.find_elements({ css: '.content .newTicket div[data-name=body]' })[0].text value = instance.find_elements(css: '.content .newTicket div[data-name=body]')[0].text
#puts "V #{value.inspect}" #puts "V #{value.inspect}"
if value != data[:body] if value != data[:body]
body_quoted = quote(data[:body]) body_quoted = quote(data[:body])
@ -1314,7 +1351,7 @@ wait untill text in selector disabppears
end end
end end
if data[:customer] if data[:customer]
element = instance.find_elements({ css: '.active .newTicket input[name="customer_id_completion"]' })[0] element = instance.find_elements(css: '.active .newTicket input[name="customer_id_completion"]')[0]
element.click element.click
element.clear element.clear
@ -1328,7 +1365,7 @@ wait untill text in selector disabppears
element.send_keys(:arrow_down) element.send_keys(:arrow_down)
sleep 0.3 sleep 0.3
element.send_keys(:enter) element.send_keys(:enter)
#instance.find_elements({ css: '.active .newTicket .recipientList-entry.js-user.is-active' })[0].click #instance.find_elements(css: '.active .newTicket .recipientList-entry.js-user.is-active')[0].click
sleep 0.6 sleep 0.6
end end
@ -1346,7 +1383,7 @@ wait untill text in selector disabppears
end end
sleep 0.8 sleep 0.8
#instance.execute_script('$(".content.active .newTicket form").submit();') #instance.execute_script('$(".content.active .newTicket form").submit();')
instance.find_elements({ css: '.active .newTicket button.js-submit' })[0].click instance.find_elements(css: '.active .newTicket button.js-submit')[0].click
sleep 1 sleep 1
(1..10).each { (1..10).each {
if instance.current_url =~ /#{Regexp.quote('#ticket/zoom/')}/ if instance.current_url =~ /#{Regexp.quote('#ticket/zoom/')}/
@ -1356,7 +1393,7 @@ wait untill text in selector disabppears
id.gsub!(//,) id.gsub!(//,)
id.gsub!(%r{^.+?/(\d+)$}, '\\1') id.gsub!(%r{^.+?/(\d+)$}, '\\1')
element = instance.find_elements({ css: '.active .ticketZoom-header .ticket-number' })[0] element = instance.find_elements(css: '.active .ticketZoom-header .ticket-number')[0]
if element if element
number = element.text number = element.text
ticket = { ticket = {
@ -1400,10 +1437,10 @@ wait untill text in selector disabppears
data = params[:data] data = params[:data]
if data[:title] if data[:title]
#element = instance.find_elements({ :css => '.content.active .ticketZoom-header .ticket-title-update' })[0] #element = instance.find_elements(:css => '.content.active .ticketZoom-header .ticket-title-update')[0]
#element.clear #element.clear
#sleep 0.5 #sleep 0.5
#element = instance.find_elements({ :css => '.content.active .ticketZoom-header .ticket-title-update' })[0] #element = instance.find_elements(:css => '.content.active .ticketZoom-header .ticket-title-update')[0]
#element.send_keys(data[:title]) #element.send_keys(data[:title])
#sleep 0.5 #sleep 0.5
#element.send_keys(:tab) #element.send_keys(:tab)
@ -1438,7 +1475,7 @@ wait untill text in selector disabppears
value: 'change', value: 'change',
) )
element = instance.find_elements({ css: '.modal input[name="customer_id_completion"]' })[0] element = instance.find_elements(css: '.modal input[name="customer_id_completion"]')[0]
element.click element.click
element.clear element.clear
@ -1452,7 +1489,7 @@ wait untill text in selector disabppears
element.send_keys(:arrow_down) element.send_keys(:arrow_down)
sleep 0.6 sleep 0.6
element.send_keys(:enter) element.send_keys(:enter)
#instance.find_elements({ css: '.modal .user_autocompletion .recipientList-entry.js-user.is-active' })[0].click #instance.find_elements(css: '.modal .user_autocompletion .recipientList-entry.js-user.is-active')[0].click
sleep 0.3 sleep 0.3
click(browser: instance, css: '.modal .js-submit') click(browser: instance, css: '.modal .js-submit')
@ -1475,12 +1512,12 @@ wait untill text in selector disabppears
if data[:body] if data[:body]
#instance.execute_script('$(".content.active div[data-name=body]").focus()') #instance.execute_script('$(".content.active div[data-name=body]").focus()')
sleep 0.5 sleep 0.5
element = instance.find_elements({ css: '.content.active div[data-name=body]' })[0] element = instance.find_elements(css: '.content.active div[data-name=body]')[0]
element.clear element.clear
element.send_keys(data[:body]) element.send_keys(data[:body])
# it's not working stable via selenium, use js # it's not working stable via selenium, use js
value = instance.find_elements({ css: '.content.active div[data-name=body]' })[0].text value = instance.find_elements(css: '.content.active div[data-name=body]')[0].text
if value != data[:body] if value != data[:body]
body_quoted = quote(data[:body]) body_quoted = quote(data[:body])
instance.execute_script("$('.content.active div[data-name=body]').html('#{body_quoted}').trigger('focusout')") instance.execute_script("$('.content.active div[data-name=body]').html('#{body_quoted}').trigger('focusout')")
@ -1489,21 +1526,21 @@ wait untill text in selector disabppears
end end
if data[:group] if data[:group]
element = instance.find_elements({ css: '.active .sidebar select[name="group_id"]' })[0] element = instance.find_elements(css: '.active .sidebar select[name="group_id"]')[0]
dropdown = Selenium::WebDriver::Support::Select.new(element) dropdown = Selenium::WebDriver::Support::Select.new(element)
dropdown.select_by(:text, data[:group]) dropdown.select_by(:text, data[:group])
sleep 0.2 sleep 0.2
end end
if data[:priority] if data[:priority]
element = instance.find_elements({ css: '.active .sidebar select[name="priority_id"]' })[0] element = instance.find_elements(css: '.active .sidebar select[name="priority_id"]')[0]
dropdown = Selenium::WebDriver::Support::Select.new(element) dropdown = Selenium::WebDriver::Support::Select.new(element)
dropdown.select_by(:text, data[:priority]) dropdown.select_by(:text, data[:priority])
sleep 0.2 sleep 0.2
end end
if data[:state] if data[:state]
element = instance.find_elements({ css: '.active .sidebar select[name="state_id"]' })[0] element = instance.find_elements(css: '.active .sidebar select[name="state_id"]')[0]
dropdown = Selenium::WebDriver::Support::Select.new(element) dropdown = Selenium::WebDriver::Support::Select.new(element)
dropdown.select_by(:text, data[:state]) dropdown.select_by(:text, data[:state])
sleep 0.2 sleep 0.2
@ -1516,7 +1553,7 @@ wait untill text in selector disabppears
break if found break if found
begin begin
text = instance.find_elements({ css: '.content.active .js-reset' })[0].text text = instance.find_elements(css: '.content.active .js-reset')[0].text
if text =~ /(Discard your unsaved changes.|Verwerfen der)/ if text =~ /(Discard your unsaved changes.|Verwerfen der)/
found = true found = true
end end
@ -1542,11 +1579,11 @@ wait untill text in selector disabppears
return true return true
end end
instance.find_elements({ css: '.content.active .js-submit' })[0].click instance.find_elements(css: '.content.active .js-submit')[0].click
(1..10).each { (1..10).each {
begin begin
text = instance.find_elements({ css: '.content.active .js-reset' })[0].text text = instance.find_elements(css: '.content.active .js-reset')[0].text
if !text || text.empty? if !text || text.empty?
screenshot(browser: instance, comment: 'ticket_update_ok') screenshot(browser: instance, comment: 'ticket_update_ok')
return true return true
@ -1582,7 +1619,7 @@ wait untill text in selector disabppears
data = params[:data] data = params[:data]
if data[:title] if data[:title]
title = instance.find_elements({ css: '.content.active .ticketZoom-header .ticket-title-update' })[0].text.strip title = instance.find_elements(css: '.content.active .ticketZoom-header .ticket-title-update')[0].text.strip
if title =~ /#{data[:title]}/i if title =~ /#{data[:title]}/i
assert(true, "matching '#{data[:title]}' in title '#{title}'") assert(true, "matching '#{data[:title]}' in title '#{title}'")
else else
@ -1591,7 +1628,7 @@ wait untill text in selector disabppears
end end
if data[:body] if data[:body]
body = instance.find_elements({ css: '.content.active [data-name="body"]' })[0].text.strip body = instance.find_elements(css: '.content.active [data-name="body"]')[0].text.strip
if body =~ /#{data[:body]}/i if body =~ /#{data[:body]}/i
assert(true, "matching '#{data[:body]}' in body '#{body}'") assert(true, "matching '#{data[:body]}' in body '#{body}'")
else else
@ -1617,21 +1654,21 @@ wait untill text in selector disabppears
instance = params[:browser] || @browser instance = params[:browser] || @browser
instance.find_elements({ css: '.js-overviewsMenuItem' })[0].click instance.find_elements(css: '.js-overviewsMenuItem')[0].click
sleep 1 sleep 1
execute( execute(
browser: instance, browser: instance,
js: '$(".content.active .sidebar").css("display", "block")', js: '$(".content.active .sidebar").css("display", "block")',
) )
instance.find_elements({ css: ".content.active .sidebar a[href=\"#{params[:link]}\"]" })[0].click instance.find_elements(css: ".content.active .sidebar a[href=\"#{params[:link]}\"]")[0].click
sleep 1 sleep 1
execute( execute(
browser: instance, browser: instance,
js: '$(".content.active .sidebar").css("display", "none")', js: '$(".content.active .sidebar").css("display", "none")',
) )
instance.find_elements({ partial_link_text: params[:number] })[0].click instance.find_elements(partial_link_text: params[:number])[0].click
sleep 1 sleep 1
number = instance.find_elements({ css: '.active .ticketZoom-header .ticket-number' })[0].text number = instance.find_elements(css: '.active .ticketZoom-header .ticket-number')[0].text
if number !~ /#{params[:number]}/ if number !~ /#{params[:number]}/
screenshot(browser: instance, comment: 'ticket_open_by_overview_failed') screenshot(browser: instance, comment: 'ticket_open_by_overview_failed')
fail "unable to search/find ticket #{params[:number]}!" fail "unable to search/find ticket #{params[:number]}!"
@ -1657,31 +1694,31 @@ wait untill text in selector disabppears
instance = params[:browser] || @browser instance = params[:browser] || @browser
# search by number # search by number
element = instance.find_elements({ css: '#global-search' })[0] element = instance.find_elements(css: '#global-search')[0]
element.click element.click
element.clear element.clear
element.send_keys(params[:number]) element.send_keys(params[:number])
sleep 3 sleep 3
# empty search box by x # empty search box by x
instance.find_elements({ css: '.search .empty-search' })[0].click instance.find_elements(css: '.search .empty-search')[0].click
sleep 0.5 sleep 0.5
text = instance.find_elements({ css: '#global-search' })[0].attribute('value') text = instance.find_elements(css: '#global-search')[0].attribute('value')
if !text if !text
fail '#global-search is not empty!' fail '#global-search is not empty!'
end end
# search by number again # search by number again
element = instance.find_elements({ css: '#global-search' })[0] element = instance.find_elements(css: '#global-search')[0]
element.click element.click
element.clear element.clear
element.send_keys(params[:number]) element.send_keys(params[:number])
sleep 1 sleep 1
# open ticket # open ticket
#instance.find_element({ partial_link_text: params[:number] } ).click #instance.find_element(partial_link_text: params[:number] } ).click
instance.execute_script("$(\"#global-search-result a:contains('#{params[:value]}') .nav-tab-icon\").click()") instance.execute_script("$(\"#global-search-result a:contains('#{params[:value]}') .nav-tab-icon\").click()")
number = instance.find_elements({ css: '.active .ticketZoom-header .ticket-number' })[0].text number = instance.find_elements(css: '.active .ticketZoom-header .ticket-number')[0].text
if number !~ /#{params[:number]}/ if number !~ /#{params[:number]}/
screenshot(browser: instance, comment: 'ticket_open_by_search_failed') screenshot(browser: instance, comment: 'ticket_open_by_search_failed')
fail "unable to search/find ticket #{params[:number]}!" fail "unable to search/find ticket #{params[:number]}!"
@ -1706,16 +1743,16 @@ wait untill text in selector disabppears
instance = params[:browser] || @browser instance = params[:browser] || @browser
# search by number # search by number
element = instance.find_elements({ css: '#global-search' })[0] element = instance.find_elements(css: '#global-search')[0]
element.click element.click
element.clear element.clear
element.send_keys(params[:title]) element.send_keys(params[:title])
sleep 3 sleep 3
# open ticket # open ticket
#instance.find_element({ partial_link_text: params[:title] } ).click #instance.find_element(partial_link_text: params[:title] } ).click
instance.execute_script("$(\"#global-search-result a:contains('#{params[:title]}') .nav-tab-icon\").click()") instance.execute_script("$(\"#global-search-result a:contains('#{params[:title]}') .nav-tab-icon\").click()")
title = instance.find_elements({ css: '.active .ticketZoom-header .ticket-title-update' })[0].text title = instance.find_elements(css: '.active .ticketZoom-header .ticket-title-update')[0].text
if title !~ /#{params[:title]}/ if title !~ /#{params[:title]}/
screenshot(browser: instance, comment: 'ticket_open_by_title_failed') screenshot(browser: instance, comment: 'ticket_open_by_title_failed')
fail "unable to search/find ticket #{params[:title]}!" fail "unable to search/find ticket #{params[:title]}!"
@ -1743,7 +1780,7 @@ wait untill text in selector disabppears
instance = params[:browser] || @browser instance = params[:browser] || @browser
instance.find_elements({ css: '.js-overviewsMenuItem' })[0].click instance.find_elements(css: '.js-overviewsMenuItem')[0].click
sleep 2 sleep 2
execute( execute(
@ -1756,7 +1793,7 @@ wait untill text in selector disabppears
#) #)
overviews = {} overviews = {}
instance.find_elements({ css: '.content.active .sidebar a[href]' }).each {|element| instance.find_elements(css: '.content.active .sidebar a[href]').each {|element|
url = element.attribute('href') url = element.attribute('href')
url.gsub!(%r{(http|https)://.+?/(.+?)$}, '\\2') url.gsub!(%r{(http|https)://.+?/(.+?)$}, '\\2')
overviews[url] = 0 overviews[url] = 0
@ -1764,7 +1801,7 @@ wait untill text in selector disabppears
#puts element.inspect #puts element.inspect
} }
overviews.each {|url, _value| overviews.each {|url, _value|
count = instance.find_elements({ css: ".content.active .sidebar a[href=\"#{url}\"] .badge" })[0].text count = instance.find_elements(css: ".content.active .sidebar a[href=\"#{url}\"] .badge")[0].text
overviews[url] = count.to_i overviews[url] = count.to_i
} }
log('overview_counter', overviews) log('overview_counter', overviews)
@ -1786,26 +1823,26 @@ wait untill text in selector disabppears
instance = params[:browser] || @browser instance = params[:browser] || @browser
element = instance.find_elements({ css: '#global-search' })[0] element = instance.find_elements(css: '#global-search')[0]
element.click element.click
element.clear element.clear
element.send_keys(params[:value]) element.send_keys(params[:value])
sleep 3 sleep 3
instance.find_elements({ css: '.search .empty-search' })[0].click instance.find_elements(css: '.search .empty-search')[0].click
sleep 0.5 sleep 0.5
text = instance.find_elements({ css: '#global-search' })[0].attribute('value') text = instance.find_elements(css: '#global-search')[0].attribute('value')
if !text if !text
fail '#global-search is not empty!' fail '#global-search is not empty!'
end end
element = instance.find_elements({ css: '#global-search' })[0] element = instance.find_elements(css: '#global-search')[0]
element.click element.click
element.clear element.clear
element.send_keys(params[:value]) element.send_keys(params[:value])
sleep 2 sleep 2
#instance.find_element({ partial_link_text: params[:value] } ).click #instance.find_element(partial_link_text: params[:value] } ).click
instance.execute_script("$(\"#global-search-result a:contains('#{params[:value]}') .nav-tab-icon\").click()") instance.execute_script("$(\"#global-search-result a:contains('#{params[:value]}') .nav-tab-icon\").click()")
name = instance.find_elements({ css: '.active h1' })[0].text name = instance.find_elements(css: '.active h1')[0].text
if name !~ /#{params[:value]}/ if name !~ /#{params[:value]}/
screenshot(browser: instance, comment: 'organization_open_by_search_failed') screenshot(browser: instance, comment: 'organization_open_by_search_failed')
fail "unable to search/find org #{params[:value]}!" fail "unable to search/find org #{params[:value]}!"
@ -1830,14 +1867,14 @@ wait untill text in selector disabppears
instance = params[:browser] || @browser instance = params[:browser] || @browser
element = instance.find_elements({ css: '#global-search' })[0] element = instance.find_elements(css: '#global-search')[0]
element.click element.click
element.clear element.clear
element.send_keys(params[:value]) element.send_keys(params[:value])
sleep 3 sleep 3
#instance.find_element({ partial_link_text: params[:value] }).click #instance.find_element(partial_link_text: params[:value]).click
instance.execute_script("$(\"#global-search-result a:contains('#{params[:value]}') .nav-tab-icon\").click()") instance.execute_script("$(\"#global-search-result a:contains('#{params[:value]}') .nav-tab-icon\").click()")
name = instance.find_elements({ css: '.active h1' })[0].text name = instance.find_elements(css: '.active h1')[0].text
if name !~ /#{params[:value]}/ if name !~ /#{params[:value]}/
screenshot(browser: instance, comment: 'user_open_by_search_failed') screenshot(browser: instance, comment: 'user_open_by_search_failed')
fail "unable to search/find user #{params[:value]}!" fail "unable to search/find user #{params[:value]}!"
@ -1869,29 +1906,29 @@ wait untill text in selector disabppears
instance = params[:browser] || @browser instance = params[:browser] || @browser
data = params[:data] data = params[:data]
instance.find_elements({ css: 'a[href="#manage"]' })[0].click instance.find_elements(css: 'a[href="#manage"]')[0].click
sleep 1 sleep 1
instance.find_elements({ css: 'a[href="#manage/users"]' })[0].click instance.find_elements(css: 'a[href="#manage/users"]')[0].click
sleep 2 sleep 2
instance.find_elements({ css: 'a[data-type="new"]' })[0].click instance.find_elements(css: 'a[data-type="new"]')[0].click
sleep 2 sleep 2
element = instance.find_elements({ css: '.modal input[name=firstname]' })[0] element = instance.find_elements(css: '.modal input[name=firstname]')[0]
element.clear element.clear
element.send_keys(data[:firstname]) element.send_keys(data[:firstname])
element = instance.find_elements({ css: '.modal input[name=lastname]' })[0] element = instance.find_elements(css: '.modal input[name=lastname]')[0]
element.clear element.clear
element.send_keys(data[:lastname]) element.send_keys(data[:lastname])
element = instance.find_elements({ css: '.modal input[name=email]' })[0] element = instance.find_elements(css: '.modal input[name=email]')[0]
element.clear element.clear
element.send_keys(data[:email]) element.send_keys(data[:email])
element = instance.find_elements({ css: '.modal input[name=password]' })[0] element = instance.find_elements(css: '.modal input[name=password]')[0]
element.clear element.clear
element.send_keys(data[:password]) element.send_keys(data[:password])
element = instance.find_elements({ css: '.modal input[name=password_confirm]' })[0] element = instance.find_elements(css: '.modal input[name=password_confirm]')[0]
element.clear element.clear
element.send_keys(data[:password]) element.send_keys(data[:password])
instance.find_elements({ css: '.modal input[name="role_ids"][value="3"]' })[0].click instance.find_elements(css: '.modal input[name="role_ids"][value="3"]')[0].click
instance.find_elements({ css: '.modal button.js-submit' })[0].click instance.find_elements(css: '.modal button.js-submit')[0].click
sleep 3.5 sleep 3.5
set( set(
browser: instance, browser: instance,
@ -1926,21 +1963,21 @@ wait untill text in selector disabppears
instance = params[:browser] || @browser instance = params[:browser] || @browser
data = params[:data] data = params[:data]
instance.find_elements({ css: 'a[href="#manage"]' })[0].click instance.find_elements(css: 'a[href="#manage"]')[0].click
sleep 1 sleep 1
instance.find_elements({ css: 'a[href="#manage/slas"]' })[0].click instance.find_elements(css: 'a[href="#manage/slas"]')[0].click
sleep 2 sleep 2
instance.find_elements({ css: 'a.js-new' })[0].click instance.find_elements(css: 'a.js-new')[0].click
sleep 2 sleep 2
element = instance.find_elements({ css: '.modal input[name=name]' })[0] element = instance.find_elements(css: '.modal input[name=name]')[0]
element.clear element.clear
element.send_keys(data[:name]) element.send_keys(data[:name])
element = instance.find_elements({ css: '.modal input[name=first_response_time_in_text]' })[0] element = instance.find_elements(css: '.modal input[name=first_response_time_in_text]')[0]
element.clear element.clear
element.send_keys(data[:first_response_time_in_text]) element.send_keys(data[:first_response_time_in_text])
instance.find_elements({ css: '.modal button.js-submit' })[0].click instance.find_elements(css: '.modal button.js-submit')[0].click
(1..8).each { (1..8).each {
element = instance.find_elements({ css: 'body' })[0] element = instance.find_elements(css: 'body')[0]
text = element.text text = element.text
if text =~ /#{Regexp.quote(data[:name])}/ if text =~ /#{Regexp.quote(data[:name])}/
assert(true, 'sla created') assert(true, 'sla created')
@ -1972,24 +2009,24 @@ wait untill text in selector disabppears
instance = params[:browser] || @browser instance = params[:browser] || @browser
data = params[:data] data = params[:data]
instance.find_elements({ css: 'a[href="#manage"]' })[0].click instance.find_elements(css: 'a[href="#manage"]')[0].click
sleep 1 sleep 1
instance.find_elements({ css: 'a[href="#manage/text_modules"]' })[0].click instance.find_elements(css: 'a[href="#manage/text_modules"]')[0].click
sleep 2 sleep 2
instance.find_elements({ css: 'a[data-type="new"]' })[0].click instance.find_elements(css: 'a[data-type="new"]')[0].click
sleep 2 sleep 2
element = instance.find_elements({ css: '.modal input[name=name]' })[0] element = instance.find_elements(css: '.modal input[name=name]')[0]
element.clear element.clear
element.send_keys(data[:name]) element.send_keys(data[:name])
element = instance.find_elements({ css: '.modal input[name=keywords]' })[0] element = instance.find_elements(css: '.modal input[name=keywords]')[0]
element.clear element.clear
element.send_keys(data[:keywords]) element.send_keys(data[:keywords])
element = instance.find_elements({ css: '.modal [data-name=content]' })[0] element = instance.find_elements(css: '.modal [data-name=content]')[0]
element.clear element.clear
element.send_keys(data[:content]) element.send_keys(data[:content])
instance.find_elements({ css: '.modal button.js-submit' })[0].click instance.find_elements(css: '.modal button.js-submit')[0].click
(1..8).each { (1..8).each {
element = instance.find_elements({ css: 'body' })[0] element = instance.find_elements(css: 'body')[0]
text = element.text text = element.text
if text =~ /#{Regexp.quote(data[:name])}/ if text =~ /#{Regexp.quote(data[:name])}/
assert(true, 'text module created') assert(true, 'text module created')
@ -2020,23 +2057,23 @@ wait untill text in selector disabppears
instance = params[:browser] || @browser instance = params[:browser] || @browser
data = params[:data] data = params[:data]
instance.find_elements({ css: 'a[href="#manage"]' })[0].click instance.find_elements(css: 'a[href="#manage"]')[0].click
sleep 1 sleep 1
instance.find_elements({ css: 'a[href="#channels/email"]' })[0].click instance.find_elements(css: 'a[href="#channels/email"]')[0].click
sleep 1 sleep 1
instance.find_elements({ css: 'a[href="#c-signature"]' })[0].click instance.find_elements(css: 'a[href="#c-signature"]')[0].click
sleep 8 sleep 8
instance.find_elements({ css: '#content #c-signature a[data-type="new"]' })[0].click instance.find_elements(css: '#content #c-signature a[data-type="new"]')[0].click
sleep 2 sleep 2
element = instance.find_elements({ css: '.modal input[name=name]' })[0] element = instance.find_elements(css: '.modal input[name=name]')[0]
element.clear element.clear
element.send_keys(data[:name]) element.send_keys(data[:name])
element = instance.find_elements({ css: '.modal [data-name=body]' })[0] element = instance.find_elements(css: '.modal [data-name=body]')[0]
element.clear element.clear
element.send_keys(data[:body]) element.send_keys(data[:body])
instance.find_elements({ css: '.modal button.js-submit' })[0].click instance.find_elements(css: '.modal button.js-submit')[0].click
(1..12).each { (1..12).each {
element = instance.find_elements({ css: 'body' })[0] element = instance.find_elements(css: 'body')[0]
text = element.text text = element.text
if text =~ /#{Regexp.quote(data[:name])}/ if text =~ /#{Regexp.quote(data[:name])}/
assert(true, 'signature created') assert(true, 'signature created')
@ -2070,27 +2107,27 @@ wait untill text in selector disabppears
instance = params[:browser] || @browser instance = params[:browser] || @browser
data = params[:data] data = params[:data]
instance.find_elements({ css: 'a[href="#manage"]' })[0].click instance.find_elements(css: 'a[href="#manage"]')[0].click
sleep 0.5 sleep 0.5
instance.find_elements({ css: 'a[href="#manage/groups"]' })[0].click instance.find_elements(css: 'a[href="#manage/groups"]')[0].click
sleep 2 sleep 2
instance.find_elements({ css: 'a[data-type="new"]' })[0].click instance.find_elements(css: 'a[data-type="new"]')[0].click
sleep 2 sleep 2
element = instance.find_elements({ css: '.modal input[name=name]' })[0] element = instance.find_elements(css: '.modal input[name=name]')[0]
element.clear element.clear
element.send_keys(data[:name]) element.send_keys(data[:name])
element = instance.find_elements({ css: '.modal select[name="email_address_id"]' })[0] element = instance.find_elements(css: '.modal select[name="email_address_id"]')[0]
dropdown = Selenium::WebDriver::Support::Select.new(element) dropdown = Selenium::WebDriver::Support::Select.new(element)
dropdown.select_by(:index, 1) dropdown.select_by(:index, 1)
#dropdown.select_by(:text, action[:group]) #dropdown.select_by(:text, action[:group])
if data[:signature] if data[:signature]
element = instance.find_elements({ css: '.modal select[name="signature_id"]' })[0] element = instance.find_elements(css: '.modal select[name="signature_id"]')[0]
dropdown = Selenium::WebDriver::Support::Select.new(element) dropdown = Selenium::WebDriver::Support::Select.new(element)
dropdown.select_by(:text, data[:signature]) dropdown.select_by(:text, data[:signature])
end end
instance.find_elements({ css: '.modal button.js-submit' })[0].click instance.find_elements(css: '.modal button.js-submit')[0].click
(1..12).each { (1..12).each {
element = instance.find_elements({ css: 'body' })[0] element = instance.find_elements(css: 'body')[0]
text = element.text text = element.text
if text =~ /#{Regexp.quote(data[:name])}/ if text =~ /#{Regexp.quote(data[:name])}/
assert(true, 'group created') assert(true, 'group created')
@ -2098,20 +2135,20 @@ wait untill text in selector disabppears
# add member # add member
if data[:member] if data[:member]
data[:member].each {|login| data[:member].each {|login|
instance.find_elements({ css: 'a[href="#manage"]' })[0].click instance.find_elements(css: 'a[href="#manage"]')[0].click
sleep 0.5 sleep 0.5
instance.find_elements({ css: 'a[href="#manage/users"]' })[0].click instance.find_elements(css: 'a[href="#manage/users"]')[0].click
sleep 3 sleep 3
element = instance.find_elements({ css: '#content [name="search"]' })[0] element = instance.find_elements(css: '#content [name="search"]')[0]
element.clear element.clear
element.send_keys(login) element.send_keys(login)
sleep 3 sleep 3
#instance.find_elements({ :css => '#content table [data-id]' })[0].click #instance.find_elements(:css => '#content table [data-id]')[0].click
instance.execute_script('$("#content table [data-id] td").first().click()') instance.execute_script('$("#content table [data-id] td").first().click()')
sleep 3 sleep 3
#instance.find_elements({ :css => 'label:contains(" ' + action[:name] + '")' })[0].click #instance.find_elements(:css => 'label:contains(" ' + action[:name] + '")')[0].click
instance.execute_script('$(\'label:contains(" ' + data[:name] + '")\').first().click()') instance.execute_script('$(\'label:contains(" ' + data[:name] + '")\').first().click()')
instance.find_elements({ css: '.modal button.js-submit' })[0].click instance.find_elements(css: '.modal button.js-submit')[0].click
} }
end end
end end