2015-04-27 12:51:43 +00:00
|
|
|
ENV['RAILS_ENV'] = 'test'
|
2015-07-03 17:36:13 +00:00
|
|
|
# rubocop:disable HandleExceptions, ClassVars, NonLocalExitFromIterator
|
2012-12-14 10:14:48 +00:00
|
|
|
require File.expand_path('../../config/environment', __FILE__)
|
2013-02-23 22:54:48 +00:00
|
|
|
require 'selenium-webdriver'
|
2012-12-14 10:14:48 +00:00
|
|
|
|
2013-02-23 22:54:48 +00:00
|
|
|
class TestCase < Test::Unit::TestCase
|
2015-03-08 01:06:57 +00:00
|
|
|
@@debug = true
|
2013-06-25 14:00:28 +00:00
|
|
|
def browser
|
|
|
|
ENV['BROWSER'] || 'firefox'
|
|
|
|
end
|
|
|
|
|
2015-07-16 13:14:06 +00:00
|
|
|
def profile
|
|
|
|
browser_profile = nil
|
|
|
|
if browser == 'firefox'
|
|
|
|
browser_profile = Selenium::WebDriver::Firefox::Profile.new
|
|
|
|
|
|
|
|
browser_profile['intl.locale.matchOS'] = false
|
|
|
|
browser_profile['intl.accept_languages'] = 'en-US'
|
|
|
|
browser_profile['general.useragent.locale'] = 'en-US'
|
|
|
|
elsif browser == 'chrome'
|
2015-12-18 19:32:00 +00:00
|
|
|
|
|
|
|
# profile are only working on remote selenium
|
|
|
|
if ENV['REMOTE_URL']
|
|
|
|
browser_profile = Selenium::WebDriver::Chrome::Profile.new
|
|
|
|
browser_profile['intl.accept_languages'] = 'en'
|
|
|
|
end
|
2015-07-16 13:14:06 +00:00
|
|
|
end
|
|
|
|
browser_profile
|
|
|
|
end
|
|
|
|
|
2013-06-25 14:00:28 +00:00
|
|
|
def browser_support_cookies
|
|
|
|
if browser =~ /(internet_explorer|ie)/i
|
|
|
|
return false
|
|
|
|
end
|
2015-04-27 19:56:07 +00:00
|
|
|
true
|
2013-06-25 14:00:28 +00:00
|
|
|
end
|
|
|
|
|
2013-02-23 22:54:48 +00:00
|
|
|
def browser_url
|
|
|
|
ENV['BROWSER_URL'] || 'http://localhost:3000'
|
|
|
|
end
|
|
|
|
|
|
|
|
def browser_instance
|
|
|
|
if !@browsers
|
2014-12-14 13:13:46 +00:00
|
|
|
@browsers = {}
|
2013-02-23 22:54:48 +00:00
|
|
|
end
|
2013-08-11 07:56:58 +00:00
|
|
|
if !ENV['REMOTE_URL'] || ENV['REMOTE_URL'].empty?
|
2015-12-14 10:02:49 +00:00
|
|
|
local_browser = Selenium::WebDriver.for(browser.to_sym, profile: profile)
|
2014-12-14 13:13:46 +00:00
|
|
|
@browsers[local_browser.hash] = local_browser
|
2015-12-17 23:02:31 +00:00
|
|
|
browser_instance_preferences(local_browser)
|
2013-06-25 14:00:28 +00:00
|
|
|
return local_browser
|
2013-02-23 22:54:48 +00:00
|
|
|
end
|
|
|
|
|
2016-05-21 15:40:08 +00:00
|
|
|
# avoid "Cannot read property 'get_Current' of undefined" issues
|
|
|
|
(1..5).each {|count|
|
|
|
|
begin
|
|
|
|
local_browser = browser_instance_remote
|
|
|
|
break
|
|
|
|
rescue
|
2016-05-21 15:43:17 +00:00
|
|
|
wait_until_ready = rand(9) + 5
|
2016-05-21 15:40:08 +00:00
|
|
|
sleep wait_until_ready
|
|
|
|
log('browser_instance', { rescure: true, count: count, sleep: wait_until_ready })
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
local_browser
|
|
|
|
end
|
|
|
|
|
|
|
|
def browser_instance_remote
|
2015-12-14 10:02:49 +00:00
|
|
|
caps = Selenium::WebDriver::Remote::Capabilities.send(browser)
|
2015-01-23 22:24:03 +00:00
|
|
|
if ENV['BROWSER_OS']
|
|
|
|
caps.platform = ENV['BROWSER_OS']
|
|
|
|
end
|
|
|
|
if ENV['BROWSER_VERSION']
|
|
|
|
caps.version = ENV['BROWSER_VERSION']
|
|
|
|
end
|
2013-06-25 14:00:28 +00:00
|
|
|
local_browser = Selenium::WebDriver.for(
|
2013-02-23 22:54:48 +00:00
|
|
|
:remote,
|
2015-04-27 13:42:53 +00:00
|
|
|
url: ENV['REMOTE_URL'],
|
|
|
|
desired_capabilities: caps,
|
2013-02-23 22:54:48 +00:00
|
|
|
)
|
2015-12-14 23:52:26 +00:00
|
|
|
@browsers[local_browser.hash] = local_browser
|
2016-05-21 15:40:08 +00:00
|
|
|
browser_instance_preferences(local_browser)
|
2015-12-14 23:52:26 +00:00
|
|
|
|
2015-12-18 10:48:22 +00:00
|
|
|
# upload files from remote dir
|
|
|
|
local_browser.file_detector = lambda do |args|
|
|
|
|
str = args.first.to_s
|
|
|
|
str if File.file?(str)
|
|
|
|
end
|
|
|
|
|
2015-04-27 19:56:07 +00:00
|
|
|
local_browser
|
2013-02-23 22:54:48 +00:00
|
|
|
end
|
2014-12-14 13:13:46 +00:00
|
|
|
|
|
|
|
def browser_instance_close(local_browser)
|
|
|
|
return if !@browsers[local_browser.hash]
|
2015-12-14 23:52:26 +00:00
|
|
|
@browsers.delete(local_browser.hash)
|
2014-12-14 13:13:46 +00:00
|
|
|
local_browser.quit
|
|
|
|
end
|
|
|
|
|
2013-07-24 18:09:20 +00:00
|
|
|
def browser_instance_preferences(local_browser)
|
2015-05-14 20:17:23 +00:00
|
|
|
local_browser.manage.window.resize_to(1024, 800)
|
2015-05-03 16:00:18 +00:00
|
|
|
if ENV['REMOTE_URL'] !~ /saucelabs|(grid|ci)\.(zammad\.org|znuny\.com)/i
|
2015-12-17 23:02:31 +00:00
|
|
|
if @browsers.count == 1
|
2013-07-24 18:09:20 +00:00
|
|
|
local_browser.manage.window.move_to(0, 0)
|
|
|
|
else
|
|
|
|
local_browser.manage.window.move_to(1024, 0)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
local_browser.manage.timeouts.implicit_wait = 3 # seconds
|
|
|
|
end
|
2013-02-23 22:54:48 +00:00
|
|
|
|
|
|
|
def teardown
|
|
|
|
return if !@browsers
|
2015-05-07 09:49:46 +00:00
|
|
|
@browsers.each { |_hash, local_browser|
|
2015-12-14 23:52:26 +00:00
|
|
|
screenshot(browser: local_browser, comment: 'teardown')
|
2014-12-14 13:13:46 +00:00
|
|
|
browser_instance_close(local_browser)
|
|
|
|
}
|
2013-02-23 22:54:48 +00:00
|
|
|
end
|
2012-12-14 10:14:48 +00:00
|
|
|
|
2015-05-04 06:13:14 +00:00
|
|
|
def screenshot(params)
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
comment = params[:comment] || ''
|
2015-05-04 14:23:33 +00:00
|
|
|
filename = "tmp/#{Time.zone.now.strftime('screenshot_%Y_%m_%d__%H_%M_%S')}_#{comment}_#{instance.hash}.png"
|
2015-05-04 14:17:36 +00:00
|
|
|
log('screenshot', { filename: filename })
|
2015-05-04 06:13:14 +00:00
|
|
|
instance.save_screenshot(filename)
|
|
|
|
end
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
username = login(
|
2015-11-17 09:03:51 +00:00
|
|
|
browser: browser1,
|
|
|
|
username: 'someuser',
|
|
|
|
password: 'somepassword',
|
|
|
|
url: 'some url', # optional
|
|
|
|
remember_me: true, # optional
|
2015-12-31 01:04:45 +00:00
|
|
|
auto_wizard: false, # optional, in case of auto wizard, skip login
|
2016-05-25 07:19:45 +00:00
|
|
|
success: false, #optional
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def login(params)
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('login', params)
|
2015-02-22 12:28:34 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
|
|
|
if params[:url]
|
2015-12-18 10:48:22 +00:00
|
|
|
instance.get(params[:url])
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
|
2016-03-22 10:50:12 +00:00
|
|
|
# submit logs anyway
|
|
|
|
instance.execute_script('App.Track.force()')
|
|
|
|
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: '#login input[name="username"]')[0]
|
2015-02-22 12:28:34 +00:00
|
|
|
if !element
|
2015-12-31 01:04:45 +00:00
|
|
|
|
|
|
|
if params[:auto_wizard]
|
2015-12-31 01:29:49 +00:00
|
|
|
watch_for(
|
|
|
|
browser: instance,
|
|
|
|
css: 'body',
|
|
|
|
value: 'auto wizard is enabled',
|
|
|
|
timeout: 10,
|
|
|
|
)
|
2016-03-21 19:10:01 +00:00
|
|
|
location(url: "#{browser_url}/#getting_started/auto_wizard")
|
2015-12-31 01:04:45 +00:00
|
|
|
sleep 10
|
2016-02-25 12:45:46 +00:00
|
|
|
login = instance.find_elements(css: '.user-menu .user a')[0].attribute('title')
|
2015-12-31 01:04:45 +00:00
|
|
|
if login != params[:username]
|
|
|
|
screenshot(browser: instance, comment: 'auto wizard login failed')
|
2016-03-01 14:26:46 +00:00
|
|
|
raise 'auto wizard login failed'
|
2015-12-31 01:04:45 +00:00
|
|
|
end
|
|
|
|
assert(true, 'auto wizard login ok')
|
2016-02-03 11:50:30 +00:00
|
|
|
|
2016-02-03 14:21:59 +00:00
|
|
|
clues_close(
|
|
|
|
browser: instance,
|
|
|
|
optional: true,
|
|
|
|
)
|
2016-02-03 11:50:30 +00:00
|
|
|
|
2015-12-31 01:04:45 +00:00
|
|
|
return
|
|
|
|
end
|
2015-12-18 10:48:22 +00:00
|
|
|
screenshot(browser: instance, comment: 'login_failed')
|
2016-03-01 14:26:46 +00:00
|
|
|
raise 'No login box found'
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
2015-05-04 06:13:14 +00:00
|
|
|
|
2015-12-18 10:48:22 +00:00
|
|
|
screenshot(browser: instance, comment: 'login')
|
2015-05-04 06:13:14 +00:00
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
element.clear
|
2015-12-18 10:48:22 +00:00
|
|
|
element.send_keys(params[:username])
|
2015-02-22 12:28:34 +00:00
|
|
|
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: '#login input[name="password"]')[0]
|
2015-02-22 12:28:34 +00:00
|
|
|
element.clear
|
2015-12-18 10:48:22 +00:00
|
|
|
element.send_keys(params[:password])
|
2015-02-22 12:28:34 +00:00
|
|
|
|
|
|
|
if params[:remember_me]
|
2016-02-25 12:45:46 +00:00
|
|
|
instance.find_elements(css: '#login .checkbox-replacement')[0].click
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
2016-02-25 12:45:46 +00:00
|
|
|
instance.find_elements(css: '#login button')[0].click
|
2015-02-22 12:28:34 +00:00
|
|
|
|
2016-04-04 13:54:37 +00:00
|
|
|
sleep 4
|
2016-05-25 07:19:45 +00:00
|
|
|
login_failed = false
|
|
|
|
if !instance.find_elements(css: '.user-menu .user a')[0]
|
|
|
|
login_failed = true
|
|
|
|
else
|
|
|
|
login = instance.find_elements(css: '.user-menu .user a')[0].attribute('title')
|
|
|
|
if login != params[:username]
|
|
|
|
login_failed = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if login_failed
|
|
|
|
if params[:success] == false
|
|
|
|
assert(true, 'login not successfull, like wanted')
|
|
|
|
return true
|
|
|
|
end
|
2015-12-18 10:48:22 +00:00
|
|
|
screenshot(browser: instance, comment: 'login_failed')
|
2016-03-01 14:26:46 +00:00
|
|
|
raise 'login failed'
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
2016-02-03 11:50:30 +00:00
|
|
|
|
2016-05-25 07:19:45 +00:00
|
|
|
if params[:success] == false
|
|
|
|
raise 'login successfull but should not'
|
|
|
|
end
|
|
|
|
|
2016-02-03 14:21:59 +00:00
|
|
|
clues_close(
|
|
|
|
browser: instance,
|
|
|
|
optional: true,
|
|
|
|
)
|
2016-02-03 11:50:30 +00:00
|
|
|
|
2015-12-18 10:48:22 +00:00
|
|
|
screenshot(browser: instance, comment: 'login_ok')
|
|
|
|
assert(true, 'login ok')
|
2015-02-22 12:28:34 +00:00
|
|
|
login
|
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
logout(
|
2015-11-17 09:03:51 +00:00
|
|
|
browser: browser1
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def logout(params = {})
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('logout', params)
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
2016-03-21 19:10:01 +00:00
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: 'a[href="#current_user"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: 'a[href="#logout"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
|
2015-05-07 09:49:46 +00:00
|
|
|
(1..6).each {
|
2015-03-03 09:14:57 +00:00
|
|
|
sleep 1
|
2016-02-25 12:45:46 +00:00
|
|
|
login = instance.find_elements(css: '#login')[0]
|
2015-07-03 17:36:13 +00:00
|
|
|
|
|
|
|
next if !login
|
2015-12-18 10:48:22 +00:00
|
|
|
screenshot(browser: instance, comment: 'logout_ok')
|
|
|
|
assert(true, 'logout ok')
|
2015-07-03 17:36:13 +00:00
|
|
|
return
|
2015-02-22 12:28:34 +00:00
|
|
|
}
|
2015-12-18 10:48:22 +00:00
|
|
|
screenshot(browser: instance, comment: 'logout_failed')
|
2016-03-01 14:26:46 +00:00
|
|
|
raise 'no login box found, seems logout was not successfully!'
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
|
2016-02-03 14:21:59 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
clues_close(
|
|
|
|
browser: browser1,
|
|
|
|
optional: false,
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
2016-02-03 20:44:47 +00:00
|
|
|
def clues_close(params = {})
|
2016-02-03 14:21:59 +00:00
|
|
|
switch_window_focus(params)
|
|
|
|
log('clues_close', params)
|
|
|
|
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
2016-02-25 12:45:46 +00:00
|
|
|
clues = instance.find_elements(css: '.js-modal--clue .js-close')[0]
|
2016-02-03 14:21:59 +00:00
|
|
|
if !params[:optional] && !clues
|
|
|
|
screenshot(browser: instance, comment: 'no_clues')
|
2016-03-01 14:26:46 +00:00
|
|
|
raise 'Unable to closes clues, no clues found!'
|
2016-02-03 14:21:59 +00:00
|
|
|
end
|
|
|
|
return if !clues
|
|
|
|
instance.execute_script("$('.js-modal--clue .js-close').click()")
|
|
|
|
assert(true, 'clues closed')
|
2016-04-04 13:54:37 +00:00
|
|
|
sleep 1
|
2016-02-03 14:21:59 +00:00
|
|
|
end
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
location(
|
2015-11-17 09:03:51 +00:00
|
|
|
browser: browser1,
|
|
|
|
url: 'http://someurl',
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def location(params)
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('location', params)
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
instance = params[:browser] || @browser
|
2015-12-14 23:52:26 +00:00
|
|
|
instance.get(params[:url])
|
2015-12-05 13:38:24 +00:00
|
|
|
|
|
|
|
# check if reload was successfull
|
2016-02-25 05:44:17 +00:00
|
|
|
if !instance.find_elements(css: 'body')[0] || instance.find_elements(css: 'body')[0].text =~ /unavailable or too busy/i
|
2015-12-05 13:38:24 +00:00
|
|
|
instance.navigate.refresh
|
|
|
|
end
|
2015-12-14 23:52:26 +00:00
|
|
|
screenshot(browser: instance, comment: 'location')
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
|
2015-02-22 22:20:05 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
location_check(
|
2015-11-17 09:03:51 +00:00
|
|
|
browser: browser1,
|
|
|
|
url: 'http://someurl',
|
2015-02-22 22:20:05 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def location_check(params)
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('location_check', params)
|
|
|
|
|
2015-02-22 22:20:05 +00:00
|
|
|
instance = params[:browser] || @browser
|
2016-02-25 14:20:22 +00:00
|
|
|
sleep 0.7
|
|
|
|
current_url = instance.current_url
|
|
|
|
if current_url !~ /#{Regexp.quote(params[:url])}/
|
2015-12-14 23:52:26 +00:00
|
|
|
screenshot(browser: instance, comment: 'location_check_failed')
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "url #{current_url} is not matching #{params[:url]}"
|
2015-02-22 22:20:05 +00:00
|
|
|
end
|
2016-02-25 14:20:22 +00:00
|
|
|
assert(true, "url #{current_url} is matching #{params[:url]}")
|
2015-02-22 22:20:05 +00:00
|
|
|
end
|
2015-02-22 12:28:34 +00:00
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
reload(
|
2015-11-17 09:03:51 +00:00
|
|
|
browser: browser1,
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def reload(params = {})
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('reload', params)
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
instance = params[:browser] || @browser
|
2015-12-14 23:52:26 +00:00
|
|
|
screenshot(browser: instance, comment: 'reload_before')
|
2015-02-22 12:28:34 +00:00
|
|
|
instance.navigate.refresh
|
2015-12-05 13:38:24 +00:00
|
|
|
|
|
|
|
# check if reload was successfull
|
2016-02-25 12:45:46 +00:00
|
|
|
if !instance.find_elements(css: 'body')[0] || instance.find_elements(css: 'body')[0].text =~ /unavailable or too busy/i
|
2015-12-05 13:38:24 +00:00
|
|
|
instance.navigate.refresh
|
|
|
|
end
|
2015-12-14 23:52:26 +00:00
|
|
|
screenshot(browser: instance, comment: 'reload_after')
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
click(
|
2015-11-17 09:03:51 +00:00
|
|
|
browser: browser1,
|
2015-12-05 13:38:24 +00:00
|
|
|
css: '.some_class',
|
|
|
|
fast: false, # do not wait
|
|
|
|
wait: 1, # wait 1 sec.
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
2015-04-05 22:39:01 +00:00
|
|
|
click(
|
2015-11-17 09:03:51 +00:00
|
|
|
browser: browser1,
|
2015-12-05 13:38:24 +00:00
|
|
|
text: '.partial_link_text',
|
|
|
|
fast: false, # do not wait
|
|
|
|
wait: 1, # wait 1 sec.
|
2015-04-05 22:39:01 +00:00
|
|
|
)
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
=end
|
|
|
|
|
|
|
|
def click(params)
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('click', params)
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
instance = params[:browser] || @browser
|
2015-04-05 22:39:01 +00:00
|
|
|
if params[:css]
|
2015-11-17 09:03:51 +00:00
|
|
|
|
2016-03-21 19:10:01 +00:00
|
|
|
begin
|
|
|
|
element = instance.find_elements(css: params[:css])[0]
|
|
|
|
#if element
|
|
|
|
# instance.mouse.move_to(element)
|
|
|
|
#end
|
|
|
|
element.click
|
|
|
|
rescue => e
|
|
|
|
sleep 0.5
|
|
|
|
|
|
|
|
# just try again
|
|
|
|
log('click', { rescure: true })
|
|
|
|
element = instance.find_elements(css: params[:css])[0]
|
|
|
|
#if element
|
|
|
|
# instance.mouse.move_to(element)
|
|
|
|
#end
|
|
|
|
element.click
|
|
|
|
end
|
2015-05-14 14:59:35 +00:00
|
|
|
|
2015-04-05 22:39:01 +00:00
|
|
|
else
|
2016-03-22 12:58:48 +00:00
|
|
|
sleep 0.5
|
2016-02-25 12:45:46 +00:00
|
|
|
instance.find_elements(partial_link_text: params[:text])[0].click
|
2015-04-05 22:39:01 +00:00
|
|
|
end
|
2016-03-22 12:58:48 +00:00
|
|
|
sleep 0.2 if !params[:fast]
|
2015-12-05 13:38:24 +00:00
|
|
|
sleep params[:wait] if params[:wait]
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
|
2015-11-17 09:03:51 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
scroll_to(
|
2015-11-17 18:57:15 +00:00
|
|
|
browser: browser1,
|
|
|
|
position: 'top', # botton
|
|
|
|
css: '.some_class',
|
2015-11-17 09:03:51 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def scroll_to(params)
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-11-17 09:03:51 +00:00
|
|
|
log('scroll_to', params)
|
|
|
|
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
2015-11-17 18:57:15 +00:00
|
|
|
position = 'true'
|
|
|
|
if params[:position] == 'botton'
|
|
|
|
position = 'false'
|
|
|
|
end
|
|
|
|
|
2015-11-17 09:03:51 +00:00
|
|
|
execute(
|
|
|
|
browser: instance,
|
2015-11-17 18:57:15 +00:00
|
|
|
js: "\$('#{params[:css]}').get(0).scrollIntoView(#{position})",
|
2015-11-17 09:03:51 +00:00
|
|
|
mute_log: params[:mute_log]
|
|
|
|
)
|
2016-03-22 23:12:50 +00:00
|
|
|
sleep 0.3
|
2015-11-17 09:03:51 +00:00
|
|
|
end
|
|
|
|
|
2016-03-23 07:24:25 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
modal_ready(
|
|
|
|
browser: browser1,
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
2016-03-23 07:40:05 +00:00
|
|
|
def modal_ready(params = {})
|
2016-03-23 07:24:25 +00:00
|
|
|
switch_window_focus(params)
|
|
|
|
log('modal_ready', params)
|
|
|
|
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
|
|
|
sleep 2
|
|
|
|
end
|
|
|
|
|
2015-11-05 12:34:22 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
execute(
|
2015-11-17 09:03:51 +00:00
|
|
|
browser: browser1,
|
|
|
|
js: '.some_class',
|
2015-11-05 12:34:22 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def execute(params)
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-11-05 12:34:22 +00:00
|
|
|
log('js', params)
|
|
|
|
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
if params[:js]
|
2015-12-18 16:18:09 +00:00
|
|
|
return instance.execute_script(params[:js])
|
2015-11-05 12:34:22 +00:00
|
|
|
end
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "Invalid execute params #{params.inspect}"
|
2015-11-05 12:34:22 +00:00
|
|
|
end
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
exists(
|
2015-11-29 15:39:56 +00:00
|
|
|
browser: browser1,
|
|
|
|
css: '.some_class',
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def exists(params)
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('exists', params)
|
|
|
|
|
2015-02-22 22:20:05 +00:00
|
|
|
instance = params[:browser] || @browser
|
2016-02-25 12:45:46 +00:00
|
|
|
if !instance.find_elements(css: params[:css])[0]
|
2015-12-14 23:52:26 +00:00
|
|
|
screenshot(browser: instance, comment: 'exists_failed')
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "#{params[:css]} dosn't exist, but should"
|
2015-02-22 22:20:05 +00:00
|
|
|
end
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
exists_not(
|
2015-11-29 15:39:56 +00:00
|
|
|
browser: browser1,
|
|
|
|
css: '.some_class',
|
2015-02-22 22:20:05 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def exists_not(params)
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('exists_not', params)
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
instance = params[:browser] || @browser
|
2016-02-25 12:45:46 +00:00
|
|
|
if instance.find_elements(css: params[:css])[0]
|
2015-12-14 23:52:26 +00:00
|
|
|
screenshot(browser: instance, comment: 'exists_not_failed')
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "#{params[:css]} exists but should not"
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
2015-02-22 22:20:05 +00:00
|
|
|
true
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
set(
|
2015-12-05 19:44:43 +00:00
|
|
|
browser: browser1,
|
|
|
|
css: '.some_class',
|
|
|
|
value: true,
|
|
|
|
slow: false,
|
|
|
|
blur: true,
|
|
|
|
clear: true, # todo | default: true
|
|
|
|
no_click: true,
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def set(params)
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('set', params)
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: params[:css])[0]
|
2015-12-05 19:44:43 +00:00
|
|
|
if !params[:no_click]
|
|
|
|
element.click
|
|
|
|
end
|
2015-02-22 12:28:34 +00:00
|
|
|
element.clear
|
|
|
|
|
|
|
|
if !params[:slow]
|
2015-12-14 23:52:26 +00:00
|
|
|
element.send_keys(params[:value])
|
2015-02-22 12:28:34 +00:00
|
|
|
else
|
2015-12-14 23:52:26 +00:00
|
|
|
element.send_keys('')
|
2015-02-22 12:28:34 +00:00
|
|
|
keys = params[:value].to_s.split('')
|
|
|
|
keys.each {|key|
|
|
|
|
instance.action.send_keys(key).perform
|
|
|
|
}
|
|
|
|
end
|
2015-02-26 12:41:09 +00:00
|
|
|
|
|
|
|
if params[:blur]
|
2015-12-14 23:52:26 +00:00
|
|
|
instance.execute_script("$('#{params[:css]}').blur()")
|
2015-02-26 12:41:09 +00:00
|
|
|
end
|
2015-02-28 10:40:23 +00:00
|
|
|
|
2016-03-22 12:58:48 +00:00
|
|
|
sleep 0.2
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
|
2015-02-22 22:20:05 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
select(
|
2016-03-21 12:51:55 +00:00
|
|
|
browser: browser1,
|
|
|
|
css: '.some_class',
|
|
|
|
value: 'Some Value',
|
|
|
|
deselect_all: false, # default false
|
2015-02-22 22:20:05 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def select(params)
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('select', params)
|
|
|
|
|
2015-02-22 22:20:05 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
2016-02-09 20:02:57 +00:00
|
|
|
# searchable select
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: "#{params[:css]}.js-shadow")[0]
|
2016-02-09 20:02:57 +00:00
|
|
|
if element
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: "#{params[:css]}.js-shadow + .js-input")[0]
|
2016-02-09 20:02:57 +00:00
|
|
|
element.click
|
|
|
|
element.clear
|
2016-03-23 07:24:25 +00:00
|
|
|
sleep 0.4
|
2016-03-22 12:58:48 +00:00
|
|
|
element.send_keys(params[:value])
|
|
|
|
sleep 0.2
|
2016-02-09 20:02:57 +00:00
|
|
|
element.send_keys(:enter)
|
2016-03-22 12:58:48 +00:00
|
|
|
sleep 0.2
|
2016-02-09 20:02:57 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
# native select
|
2015-02-24 01:31:17 +00:00
|
|
|
begin
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: params[:css])[0]
|
2015-02-24 01:31:17 +00:00
|
|
|
dropdown = Selenium::WebDriver::Support::Select.new(element)
|
2016-03-21 12:51:55 +00:00
|
|
|
if params[:deselect_all]
|
|
|
|
dropdown.deselect_all
|
|
|
|
end
|
2015-02-24 01:31:17 +00:00
|
|
|
dropdown.select_by(:text, params[:value])
|
2016-03-21 19:10:01 +00:00
|
|
|
#puts "select - #{params.inspect}"
|
2015-02-24 01:31:17 +00:00
|
|
|
rescue
|
2016-03-23 07:24:25 +00:00
|
|
|
sleep 0.4
|
2016-03-21 13:39:18 +00:00
|
|
|
|
2015-02-24 01:31:17 +00:00
|
|
|
# just try again
|
2016-03-21 19:10:01 +00:00
|
|
|
log('select', { rescure: true })
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: params[:css])[0]
|
2015-02-24 01:31:17 +00:00
|
|
|
dropdown = Selenium::WebDriver::Support::Select.new(element)
|
2016-03-21 12:51:55 +00:00
|
|
|
if params[:deselect_all]
|
|
|
|
dropdown.deselect_all
|
|
|
|
end
|
2015-02-24 01:31:17 +00:00
|
|
|
dropdown.select_by(:text, params[:value])
|
2016-03-21 19:10:01 +00:00
|
|
|
#puts "select2 - #{params.inspect}"
|
2015-02-24 01:31:17 +00:00
|
|
|
end
|
2016-03-23 07:24:25 +00:00
|
|
|
sleep 0.4
|
2015-02-22 22:20:05 +00:00
|
|
|
end
|
|
|
|
|
2015-12-05 13:38:24 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
switch(
|
|
|
|
browser: browser1,
|
|
|
|
css: '.some_class',
|
|
|
|
type: 'on', # 'off'
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def switch(params)
|
|
|
|
switch_window_focus(params)
|
|
|
|
log('switch', params)
|
|
|
|
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: "#{params[:css]} input[type=checkbox]")[0]
|
2015-12-05 13:38:24 +00:00
|
|
|
checked = element.attribute('checked')
|
|
|
|
if !checked
|
|
|
|
if params[:type] == 'on'
|
2016-02-25 12:45:46 +00:00
|
|
|
instance.find_elements(css: "#{params[:css]} label")[0].click
|
2015-12-05 13:38:24 +00:00
|
|
|
end
|
2016-01-15 17:22:57 +00:00
|
|
|
elsif params[:type] == 'off'
|
2016-02-25 12:45:46 +00:00
|
|
|
instance.find_elements(css: "#{params[:css]} label")[0].click
|
2015-12-05 13:38:24 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-02-23 06:56:45 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
check(
|
2015-11-27 14:47:56 +00:00
|
|
|
browser: browser1,
|
|
|
|
css: '.some_class',
|
2015-02-23 06:56:45 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def check(params)
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('check', params)
|
|
|
|
|
2015-02-23 06:56:45 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
2016-03-14 20:03:51 +00:00
|
|
|
instance.execute_script("if (!$('#{params[:css]}').prop('checked')) { $('#{params[:css]}').click() }")
|
|
|
|
#element = instance.find_elements(css: params[:css])[0]
|
|
|
|
#checked = element.attribute('checked')
|
|
|
|
#element.click if !checked
|
2015-02-23 06:56:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
uncheck(
|
2015-11-27 14:47:56 +00:00
|
|
|
browser: browser1,
|
|
|
|
css: '.some_class',
|
2015-02-23 06:56:45 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def uncheck(params)
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('uncheck', params)
|
|
|
|
|
2015-02-23 06:56:45 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
2016-03-14 20:03:51 +00:00
|
|
|
instance.execute_script("if ($('#{params[:css]}').prop('checked')) { $('#{params[:css]}').click() }")
|
|
|
|
#element = instance.find_elements(css: params[:css])[0]
|
|
|
|
#checked = element.attribute('checked')
|
|
|
|
#element.click if checked
|
2015-02-23 06:56:45 +00:00
|
|
|
end
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
sendkey(
|
2015-11-27 14:47:56 +00:00
|
|
|
browser: browser1,
|
|
|
|
value: :enter,
|
|
|
|
slow: false,
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def sendkey(params)
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('sendkey', params)
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
if params[:value].class == Array
|
|
|
|
params[:value].each {|key|
|
|
|
|
instance.action.send_keys(key).perform
|
|
|
|
}
|
|
|
|
return
|
|
|
|
end
|
|
|
|
instance.action.send_keys(params[:value]).perform
|
2015-11-27 14:47:56 +00:00
|
|
|
if params[:slow]
|
2016-03-22 12:58:48 +00:00
|
|
|
sleep 1.5
|
2015-11-27 14:47:56 +00:00
|
|
|
else
|
2016-03-22 12:58:48 +00:00
|
|
|
sleep 0.2
|
2015-11-27 14:47:56 +00:00
|
|
|
end
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
match(
|
2015-11-29 15:39:56 +00:00
|
|
|
browser: browser1,
|
|
|
|
css: '#content .text-1',
|
|
|
|
value: 'some test for browser and some other for browser',
|
|
|
|
attribute: 'some_attribute', # match on attribute
|
|
|
|
should_not_match: true,
|
|
|
|
no_quote: false, # use regex
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
2015-03-01 23:16:36 +00:00
|
|
|
def match(params, fallback = false)
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('match', params)
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
instance = params[:browser] || @browser
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: params[:css])[0]
|
2015-02-22 12:28:34 +00:00
|
|
|
|
|
|
|
if params[:css] =~ /select/
|
|
|
|
dropdown = Selenium::WebDriver::Support::Select.new(element)
|
|
|
|
success = false
|
|
|
|
if dropdown.selected_options
|
|
|
|
dropdown.selected_options.each {|option|
|
|
|
|
if option.text == params[:value]
|
|
|
|
success = true
|
|
|
|
end
|
|
|
|
}
|
|
|
|
end
|
|
|
|
if params[:should_not_match]
|
|
|
|
if success
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "should not match '#{params[:value]}' in select list, but is matching"
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
2016-01-15 17:22:57 +00:00
|
|
|
elsif !success
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "not matching '#{params[:value]}' in select list"
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
2016-01-15 17:22:57 +00:00
|
|
|
|
|
|
|
return true
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
|
2015-02-24 01:31:17 +00:00
|
|
|
# match on attribute
|
2015-02-28 10:40:23 +00:00
|
|
|
begin
|
2016-01-15 17:22:57 +00:00
|
|
|
text = if params[:attribute]
|
|
|
|
element.attribute(params[:attribute])
|
|
|
|
elsif params[:css] =~ /(input|textarea)/i
|
|
|
|
element.attribute('value')
|
|
|
|
else
|
|
|
|
element.text
|
|
|
|
end
|
2015-03-08 01:06:57 +00:00
|
|
|
rescue => e
|
2015-02-28 10:40:23 +00:00
|
|
|
|
|
|
|
# just try again
|
2015-03-01 23:16:36 +00:00
|
|
|
if !fallback
|
|
|
|
return match(params, true)
|
2015-02-28 10:40:23 +00:00
|
|
|
end
|
2016-01-15 17:22:57 +00:00
|
|
|
|
|
|
|
raise e.inspect
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
2015-04-14 14:29:26 +00:00
|
|
|
|
|
|
|
# do cleanups (needed for richtext tests)
|
2015-04-14 21:49:46 +00:00
|
|
|
if params[:cleanup]
|
|
|
|
text.gsub!(/\s+$/m, '')
|
|
|
|
params[:value].gsub!(/\s+$/m, '')
|
|
|
|
end
|
2015-04-14 14:29:26 +00:00
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
match = false
|
|
|
|
if params[:no_quote]
|
|
|
|
#puts "aaaa #{text}/#{params[:value]}"
|
|
|
|
if text =~ /#{params[:value]}/i
|
|
|
|
match = $1 || true
|
|
|
|
end
|
2016-01-15 17:22:57 +00:00
|
|
|
elsif text =~ /#{Regexp.quote(params[:value])}/i
|
|
|
|
match = true
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
2016-01-15 17:22:57 +00:00
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
if match
|
|
|
|
if params[:should_not_match]
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "matching '#{params[:value]}' in content '#{text}' but should not!"
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
2016-01-15 17:22:57 +00:00
|
|
|
elsif !params[:should_not_match]
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "not matching '#{params[:value]}' in content '#{text}' but should!"
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
2016-03-22 12:58:48 +00:00
|
|
|
sleep 0.2
|
2015-02-28 10:40:23 +00:00
|
|
|
match
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
|
2015-02-22 22:20:05 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
match_not(
|
2015-11-29 15:39:56 +00:00
|
|
|
browser: browser1,
|
|
|
|
css: '#content .text-1',
|
|
|
|
value: 'some test for browser and some other for browser',
|
|
|
|
attribute: 'some_attribute', # match on attribute
|
|
|
|
should_not_match: true,
|
|
|
|
no_quote: false, # use regex
|
2015-02-22 22:20:05 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def match_not(params)
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('match_not', params)
|
|
|
|
|
2015-02-22 22:20:05 +00:00
|
|
|
params[:should_not_match] = true
|
|
|
|
match(params)
|
|
|
|
end
|
|
|
|
|
2015-11-06 01:08:06 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
task_type(
|
2015-11-29 15:39:56 +00:00
|
|
|
browser: browser1,
|
|
|
|
type: 'stayOnTab',
|
2015-11-06 01:08:06 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def task_type(params)
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-11-06 01:08:06 +00:00
|
|
|
log('task_type', params)
|
|
|
|
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
|
|
|
if params[:type]
|
2016-02-25 12:45:46 +00:00
|
|
|
instance.find_elements(css: '.content.active .js-secondaryActionButtonLabel')[0].click
|
|
|
|
instance.find_elements(css: ".content.active .js-secondaryActionLabel[data-type=#{params[:type]}]")[0].click
|
2015-11-06 01:08:06 +00:00
|
|
|
return
|
|
|
|
end
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "Unknown params for task_type: #{params.inspect}"
|
2015-11-06 01:08:06 +00:00
|
|
|
end
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
cookie(
|
2015-11-29 15:39:56 +00:00
|
|
|
browser: browser1,
|
|
|
|
name: '^_zammad.+?',
|
|
|
|
value: '.+?',
|
|
|
|
expires: nil,
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
cookie(
|
2015-11-29 15:39:56 +00:00
|
|
|
browser: browser1,
|
|
|
|
name: '^_zammad.+?',
|
|
|
|
should_not_exist: true,
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def cookie(params)
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('cookie', params)
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
|
|
|
if !browser_support_cookies
|
2015-12-14 23:52:26 +00:00
|
|
|
assert(true, "'#{params[:value]}' ups browser is not supporting reading cookies, go ahead")
|
2015-02-22 12:28:34 +00:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
cookies = instance.manage.all_cookies
|
|
|
|
cookies.each {|cookie|
|
|
|
|
#puts "CCC #{cookie.inspect}"
|
|
|
|
# :name=>"_zammad_session_c25832f4de2", :value=>"adc31cd21615cb0a7ab269184ec8b76f", :path=>"/", :domain=>"localhost", :expires=>nil, :secure=>false}
|
2015-07-03 17:36:13 +00:00
|
|
|
next if cookie[:name] !~ /#{params[:name]}/i
|
2015-02-22 12:28:34 +00:00
|
|
|
|
2016-03-10 07:39:41 +00:00
|
|
|
if params.key?(:value) && cookie[:value].to_s =~ /#{params[:value]}/i
|
2015-12-14 23:52:26 +00:00
|
|
|
assert(true, "matching value '#{params[:value]}' in cookie '#{cookie}'")
|
2015-07-03 17:36:13 +00:00
|
|
|
else
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "not matching value '#{params[:value]}' in cookie '#{cookie}'"
|
2015-07-03 17:36:13 +00:00
|
|
|
end
|
2015-12-14 23:52:26 +00:00
|
|
|
if params.key?(:expires) && cookie[:expires].to_s =~ /#{params[:expires]}/i
|
|
|
|
assert(true, "matching expires '#{params[:expires].inspect}' in cookie '#{cookie}'")
|
2015-07-03 17:36:13 +00:00
|
|
|
else
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "not matching expires '#{params[:expires]}' in cookie '#{cookie}'"
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
2015-07-03 17:36:13 +00:00
|
|
|
|
|
|
|
return if !params[:should_not_exist]
|
|
|
|
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "cookie with name '#{params[:name]}' should not exist, but exists '#{cookies}'"
|
2015-02-22 12:28:34 +00:00
|
|
|
}
|
|
|
|
if params[:should_not_exist]
|
2015-12-14 23:52:26 +00:00
|
|
|
assert(true, "cookie with name '#{params[:name]}' is not existing")
|
2015-02-22 12:28:34 +00:00
|
|
|
return
|
|
|
|
end
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "not matching name '#{params[:name]}' in cookie '#{cookies}'"
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
|
2015-02-28 18:51:40 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
verify_title(
|
2015-11-29 15:39:56 +00:00
|
|
|
browser: browser1,
|
|
|
|
value: 'some title',
|
2015-02-28 18:51:40 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def verify_title(params = {})
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('verify_title', params)
|
|
|
|
|
2015-02-28 18:51:40 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
|
|
|
title = instance.title
|
|
|
|
if title =~ /#{params[:value]}/i
|
2015-12-14 23:52:26 +00:00
|
|
|
assert(true, "matching '#{params[:value]}' in title '#{title}'")
|
2015-02-28 18:51:40 +00:00
|
|
|
else
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "not matching '#{params[:value]}' in title '#{title}'"
|
2015-02-28 18:51:40 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
verify_task(
|
2015-11-29 15:39:56 +00:00
|
|
|
browser: browser1,
|
|
|
|
data: {
|
|
|
|
title: 'some title',
|
|
|
|
modified: true, # optional
|
2015-02-28 18:51:40 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
2015-03-01 23:16:36 +00:00
|
|
|
def verify_task(params = {}, fallback = false)
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('verify_task', params)
|
|
|
|
|
2015-02-28 18:51:40 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
data = params[:data]
|
|
|
|
|
2015-03-08 01:06:57 +00:00
|
|
|
sleep 1
|
|
|
|
|
2015-03-01 23:16:36 +00:00
|
|
|
begin
|
2015-03-08 01:06:57 +00:00
|
|
|
|
|
|
|
# verify title
|
2015-03-01 23:16:36 +00:00
|
|
|
if data[:title]
|
2016-02-25 12:45:46 +00:00
|
|
|
title = instance.find_elements(css: '.tasks .is-active')[0].text.strip
|
2015-03-01 23:16:36 +00:00
|
|
|
if title =~ /#{data[:title]}/i
|
2015-12-14 23:52:26 +00:00
|
|
|
assert(true, "matching '#{data[:title]}' in title '#{title}'")
|
2015-03-01 23:16:36 +00:00
|
|
|
else
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "not matching '#{data[:title]}' in title '#{title}'"
|
2015-03-01 23:16:36 +00:00
|
|
|
end
|
|
|
|
end
|
2015-04-27 14:56:32 +00:00
|
|
|
puts "tv #{params.inspect}"
|
2015-03-08 01:06:57 +00:00
|
|
|
# verify modified
|
2015-04-27 19:56:07 +00:00
|
|
|
if data.key?(:modified)
|
2016-02-25 12:45:46 +00:00
|
|
|
exists = instance.find_elements(css: '.tasks .is-active')[0]
|
|
|
|
is_modified = instance.find_elements(css: '.tasks .is-modified')[0]
|
2015-03-08 01:06:57 +00:00
|
|
|
puts "m #{data[:modified].inspect}"
|
|
|
|
if exists
|
2015-06-01 10:38:10 +00:00
|
|
|
puts ' exists'
|
2015-03-08 01:06:57 +00:00
|
|
|
end
|
|
|
|
if is_modified
|
2015-04-27 12:51:43 +00:00
|
|
|
puts ' is_modified'
|
2015-03-08 01:06:57 +00:00
|
|
|
end
|
|
|
|
if data[:modified] == true
|
|
|
|
if is_modified
|
2015-12-14 23:52:26 +00:00
|
|
|
assert(true, "task '#{data[:title]}' is modifed")
|
2015-03-08 01:06:57 +00:00
|
|
|
elsif !exists
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "task '#{data[:title]}' not exists, should not modified"
|
2015-03-08 01:06:57 +00:00
|
|
|
else
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "task '#{data[:title]}' is not modifed"
|
2015-03-08 01:06:57 +00:00
|
|
|
end
|
2016-01-15 17:22:57 +00:00
|
|
|
elsif !is_modified
|
|
|
|
assert(true, "task '#{data[:title]}' is modifed")
|
|
|
|
elsif !exists
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "task '#{data[:title]}' not exists, should be not modified"
|
2015-03-08 01:06:57 +00:00
|
|
|
else
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "task '#{data[:title]}' is modifed, but should not"
|
2015-03-08 01:06:57 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
rescue => e
|
|
|
|
|
2015-03-01 23:16:36 +00:00
|
|
|
# just try again
|
|
|
|
if !fallback
|
|
|
|
verify_task(params, true)
|
2015-02-28 18:51:40 +00:00
|
|
|
end
|
2016-01-15 17:22:57 +00:00
|
|
|
raise 'ERROR: ' + e.inspect
|
2015-02-28 18:51:40 +00:00
|
|
|
end
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2015-03-02 13:39:27 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
open_task(
|
2015-11-29 15:39:56 +00:00
|
|
|
browser: browser1,
|
|
|
|
data: {
|
|
|
|
title: 'some title',
|
2015-03-02 13:39:27 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
2016-02-29 15:00:11 +00:00
|
|
|
def open_task(params = {})
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('open_task', params)
|
|
|
|
|
2015-03-02 13:39:27 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
data = params[:data]
|
|
|
|
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(partial_link_text: data[:title])[0]
|
2015-03-02 13:39:27 +00:00
|
|
|
if !element
|
2015-12-14 23:52:26 +00:00
|
|
|
screenshot(browser: instance, comment: 'open_task_failed')
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "no task with title '#{data[:title]}' found"
|
2015-03-02 13:39:27 +00:00
|
|
|
end
|
|
|
|
element.click
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2016-02-29 15:00:11 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
close_task(
|
|
|
|
browser: browser1,
|
|
|
|
data: {
|
|
|
|
title: 'some title',
|
|
|
|
},
|
|
|
|
discard_changes: true,
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def close_task(params = {})
|
|
|
|
switch_window_focus(params)
|
|
|
|
log('close_task', params)
|
|
|
|
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
data = params[:data]
|
|
|
|
|
|
|
|
element = instance.find_elements(partial_link_text: data[:title])[0]
|
|
|
|
if !element
|
|
|
|
screenshot(browser: instance, comment: 'close_task_failed')
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "no task with title '#{data[:title]}' found"
|
2016-02-29 15:00:11 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
instance.mouse.move_to(element)
|
|
|
|
sleep 0.1
|
|
|
|
instance.execute_script("$('.navigation .tasks .task:contains(\"#{data[:title]}\") .js-close').click()")
|
|
|
|
|
|
|
|
# accept task close warning
|
|
|
|
if params[:discard_changes]
|
2016-03-23 07:24:25 +00:00
|
|
|
modal_ready()
|
2016-02-29 15:00:11 +00:00
|
|
|
instance.find_elements(css: '.modal button.js-submit')[0].click
|
|
|
|
end
|
|
|
|
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2015-02-28 10:40:23 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
file_upload(
|
2015-11-29 15:39:56 +00:00
|
|
|
browser: browser1,
|
2015-12-15 07:46:01 +00:00
|
|
|
css: '.active .attachmentPlaceholder-inputHolder input'
|
|
|
|
files: ['path/in/home/some_file.ext'], # 'test/fixtures/test1.pdf'
|
2015-02-28 10:40:23 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def file_upload(params = {})
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('file_upload', params)
|
|
|
|
|
2015-02-28 10:40:23 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
2015-12-15 07:46:01 +00:00
|
|
|
params[:files].each {|file|
|
2016-02-25 12:45:46 +00:00
|
|
|
instance.find_elements(css: params[:css])[0].send_keys "#{Rails.root}/#{file}"
|
2015-12-15 07:46:01 +00:00
|
|
|
}
|
2015-12-17 18:38:42 +00:00
|
|
|
sleep 2 * params[:files].count
|
2015-02-28 10:40:23 +00:00
|
|
|
end
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
watch_for(
|
2015-11-29 15:39:56 +00:00
|
|
|
browser: browser1,
|
|
|
|
css: '#content .text-1',
|
|
|
|
value: 'some text',
|
|
|
|
attribute: 'some_attribute' # optional
|
2016-02-02 19:17:40 +00:00
|
|
|
timeout: 16, # in sec, default 16
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def watch_for(params = {})
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('watch_for', params)
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
|
|
|
timeout = 16
|
|
|
|
if params[:timeout]
|
|
|
|
timeout = params[:timeout]
|
|
|
|
end
|
2016-01-15 17:22:57 +00:00
|
|
|
loops = timeout.to_i * 2
|
2015-02-22 12:28:34 +00:00
|
|
|
text = ''
|
2015-05-07 09:49:46 +00:00
|
|
|
(1..loops).each {
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: params[:css])[0]
|
2015-02-22 12:28:34 +00:00
|
|
|
if element #&& element.displayed?
|
|
|
|
begin
|
2015-02-24 01:31:17 +00:00
|
|
|
|
|
|
|
# match pn attribute
|
2016-01-15 17:22:57 +00:00
|
|
|
text = if params[:attribute]
|
|
|
|
element.attribute(params[:attribute])
|
|
|
|
elsif params[:css] =~ /(input|textarea)/i
|
|
|
|
element.attribute('value')
|
|
|
|
else
|
|
|
|
element.text
|
|
|
|
end
|
2015-02-22 12:28:34 +00:00
|
|
|
if text =~ /#{params[:value]}/i
|
2015-12-14 23:52:26 +00:00
|
|
|
assert(true, "'#{params[:value]}' found in '#{text}'")
|
2015-02-23 22:58:05 +00:00
|
|
|
sleep 0.5
|
2015-02-22 12:28:34 +00:00
|
|
|
return true
|
|
|
|
end
|
2015-04-28 20:44:31 +00:00
|
|
|
rescue
|
|
|
|
# try again
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
end
|
2015-03-03 13:44:19 +00:00
|
|
|
sleep 0.5
|
2015-02-22 12:28:34 +00:00
|
|
|
}
|
2015-12-14 23:52:26 +00:00
|
|
|
screenshot(browser: instance, comment: 'watch_for_failed')
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "'#{params[:value]}' found in '#{text}'"
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
|
2015-02-23 22:37:00 +00:00
|
|
|
=begin
|
|
|
|
|
2015-02-28 18:51:40 +00:00
|
|
|
wait untill selector disabppears
|
|
|
|
|
2015-02-23 22:37:00 +00:00
|
|
|
watch_for_disappear(
|
2015-11-29 15:39:56 +00:00
|
|
|
browser: browser1,
|
|
|
|
css: '#content .text-1',
|
2016-02-02 19:17:40 +00:00
|
|
|
timeout: 16, # in sec, default 16
|
2015-02-23 22:37:00 +00:00
|
|
|
)
|
|
|
|
|
2015-02-28 18:51:40 +00:00
|
|
|
wait untill text in selector disabppears
|
|
|
|
|
|
|
|
watch_for_disappear(
|
2015-11-29 15:39:56 +00:00
|
|
|
browser: browser1,
|
|
|
|
css: '#content .text-1',
|
|
|
|
value: 'some value as regexp',
|
2016-02-02 19:17:40 +00:00
|
|
|
timeout: 16, # in sec, default 16
|
2015-02-28 18:51:40 +00:00
|
|
|
)
|
|
|
|
|
2015-02-23 22:37:00 +00:00
|
|
|
=end
|
|
|
|
|
|
|
|
def watch_for_disappear(params = {})
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('watch_for_disappear', params)
|
|
|
|
|
2015-02-23 22:37:00 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
|
|
|
timeout = 16
|
2015-02-24 00:11:10 +00:00
|
|
|
if params[:timeout]
|
2015-02-23 22:37:00 +00:00
|
|
|
timeout = params[:timeout]
|
|
|
|
end
|
2016-01-15 17:22:57 +00:00
|
|
|
loops = timeout.to_i
|
2015-02-28 10:40:23 +00:00
|
|
|
text = ''
|
2015-05-07 09:49:46 +00:00
|
|
|
(1..loops).each {
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: params[:css])[0]
|
2015-02-23 22:37:00 +00:00
|
|
|
if !element #|| element.displayed?
|
2015-12-14 23:52:26 +00:00
|
|
|
assert(true, 'not found')
|
2015-02-23 22:58:05 +00:00
|
|
|
sleep 1
|
2015-02-23 22:37:00 +00:00
|
|
|
return true
|
|
|
|
end
|
2015-02-28 18:51:40 +00:00
|
|
|
if params[:value]
|
|
|
|
begin
|
2016-02-25 12:45:46 +00:00
|
|
|
text = instance.find_elements(css: params[:css])[0].text
|
2015-02-28 18:51:40 +00:00
|
|
|
if text !~ /#{params[:value]}/i
|
2015-12-14 23:52:26 +00:00
|
|
|
assert(true, "not matching '#{params[:value]}' in text '#{text}'")
|
2015-02-28 18:51:40 +00:00
|
|
|
sleep 1
|
|
|
|
return true
|
|
|
|
end
|
2015-04-28 20:44:31 +00:00
|
|
|
rescue
|
|
|
|
# try again
|
2015-02-28 18:51:40 +00:00
|
|
|
end
|
|
|
|
end
|
2015-02-23 22:37:00 +00:00
|
|
|
sleep 1
|
|
|
|
}
|
2015-12-14 23:52:26 +00:00
|
|
|
screenshot(browser: instance, comment: 'disappear_failed')
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "#{params[:css]}) still exsists"
|
2015-02-23 22:37:00 +00:00
|
|
|
end
|
2015-02-22 12:28:34 +00:00
|
|
|
|
2016-02-25 12:45:46 +00:00
|
|
|
=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
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
tasks_close_all(
|
2015-11-20 14:10:50 +00:00
|
|
|
browser: browser1,
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def tasks_close_all(params = {})
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('tasks_close_all', params)
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
2015-04-27 20:49:17 +00:00
|
|
|
(1..100).each do
|
2016-04-04 13:54:37 +00:00
|
|
|
#sleep 0.5
|
2015-02-22 22:51:44 +00:00
|
|
|
begin
|
2016-02-25 12:45:46 +00:00
|
|
|
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])
|
2015-11-20 15:26:05 +00:00
|
|
|
sleep 0.1
|
2016-02-25 12:45:46 +00:00
|
|
|
click_element = instance.find_elements(css: '.navigation .tasks .task:first-child .js-close')[0]
|
2015-02-22 22:51:44 +00:00
|
|
|
if click_element
|
|
|
|
click_element.click
|
|
|
|
|
|
|
|
# accept task close warning
|
2016-02-29 15:00:11 +00:00
|
|
|
if instance.find_elements(css: '.modal button.js-submit')[0]
|
2016-03-22 12:58:48 +00:00
|
|
|
sleep 0.4
|
2016-02-25 12:45:46 +00:00
|
|
|
instance.find_elements(css: '.modal button.js-submit')[0].click
|
2015-02-22 22:51:44 +00:00
|
|
|
end
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
2015-02-22 22:51:44 +00:00
|
|
|
else
|
|
|
|
break
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
2015-04-28 20:44:31 +00:00
|
|
|
rescue
|
|
|
|
# try again
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
end
|
2015-12-14 23:52:26 +00:00
|
|
|
assert(true, 'all tasks closed')
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
|
2016-04-04 13:54:37 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
close_online_notitifcation(
|
|
|
|
browser: browser1,
|
|
|
|
data: {
|
|
|
|
#title: 'some title',
|
|
|
|
position: 3,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def close_online_notitifcation(params = {})
|
|
|
|
switch_window_focus(params)
|
|
|
|
log('close_online_notitifcation', params)
|
|
|
|
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
data = params[:data]
|
|
|
|
|
|
|
|
if data[:title]
|
|
|
|
element = instance.find_elements(partial_link_text: data[:title])[0]
|
|
|
|
if !element
|
|
|
|
screenshot(browser: instance, comment: 'close_online_notitifcation')
|
|
|
|
raise "no online notification with title '#{data[:title]}' found"
|
|
|
|
end
|
|
|
|
instance.mouse.move_to(element)
|
|
|
|
sleep 0.1
|
|
|
|
instance.execute_script("$('.js-notificationsContainer .js-items .js-item .activity-text:contains(\"#{data[:title]}\") .js-remove').first().click()")
|
|
|
|
|
|
|
|
else
|
|
|
|
css = ".js-notificationsContainer .js-items .js-item:nth-child(#{data[:position]})"
|
|
|
|
element = instance.find_elements(css: css)[0]
|
|
|
|
if !element
|
|
|
|
screenshot(browser: instance, comment: 'close_online_notitifcation')
|
|
|
|
raise "no online notification with postion '#{css}' found"
|
|
|
|
end
|
|
|
|
|
|
|
|
instance.mouse.move_to(element)
|
|
|
|
sleep 0.1
|
|
|
|
instance.find_elements(css: "#{css} .js-remove")[0].click
|
|
|
|
end
|
|
|
|
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
online_notitifcation_close_all(
|
|
|
|
browser: browser1,
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def online_notitifcation_close_all(params = {})
|
|
|
|
switch_window_focus(params)
|
|
|
|
log('online_notitifcation_close_all', params)
|
|
|
|
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
|
|
|
(1..100).each do
|
|
|
|
sleep 0.5
|
|
|
|
begin
|
|
|
|
if instance.find_elements(css: '.js-notificationsContainer .js-item:first-child')[0]
|
|
|
|
instance.mouse.move_to(instance.find_elements(css: '.js-notificationsContainer .js-item:first-child')[0])
|
|
|
|
sleep 0.1
|
|
|
|
click_element = instance.find_elements(css: '.js-notificationsContainer .js-item:first-child .js-remove')[0]
|
|
|
|
if click_element
|
|
|
|
click_element.click
|
|
|
|
end
|
|
|
|
else
|
|
|
|
break
|
|
|
|
end
|
|
|
|
rescue
|
|
|
|
# try again
|
|
|
|
end
|
|
|
|
end
|
|
|
|
assert(true, 'all online notification closed')
|
|
|
|
end
|
|
|
|
|
2016-03-15 10:24:42 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
empty_search(
|
|
|
|
browser: browser1,
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def empty_search(params = {})
|
|
|
|
switch_window_focus(params)
|
|
|
|
log('empty_search', params)
|
|
|
|
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
|
|
|
# empty search box by x
|
|
|
|
begin
|
|
|
|
instance.find_elements(css: '.search .empty-search')[0].click
|
|
|
|
rescue
|
|
|
|
|
|
|
|
# in issues with ff & selenium, sometimes exeption appears
|
|
|
|
# "Element is not currently visible and so may not be interacted with"
|
|
|
|
log('empty_search via js')
|
|
|
|
instance.execute_script('$(".search .empty-search").click()')
|
|
|
|
end
|
|
|
|
sleep 0.5
|
|
|
|
text = instance.find_elements(css: '#global-search')[0].attribute('value')
|
|
|
|
if !text
|
|
|
|
raise '#global-search is not empty!'
|
|
|
|
end
|
|
|
|
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2015-11-29 15:39:56 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
ticket_customer_select(
|
|
|
|
browser: browser1,
|
|
|
|
css: '#content .text-1',
|
|
|
|
customer: '',
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def ticket_customer_select(params = {})
|
|
|
|
switch_window_focus(params)
|
|
|
|
log('ticket_customer_select', params)
|
|
|
|
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: params[:css] + ' input[name="customer_id_completion"]')[0]
|
2015-11-29 15:39:56 +00:00
|
|
|
element.click
|
|
|
|
element.clear
|
|
|
|
|
|
|
|
# workaround, sometimes focus is not triggered
|
2016-03-14 22:29:39 +00:00
|
|
|
element.send_keys(params[:customer])
|
2016-03-22 12:58:48 +00:00
|
|
|
sleep 2.5
|
2015-11-29 15:39:56 +00:00
|
|
|
|
2015-12-14 23:52:26 +00:00
|
|
|
element.send_keys(:enter)
|
2016-02-25 12:45:46 +00:00
|
|
|
#instance.find_elements(css: params[:css] + ' .recipientList-entry.js-user.is-active')[0].click
|
2016-03-22 12:58:48 +00:00
|
|
|
sleep 0.4
|
2015-12-14 23:52:26 +00:00
|
|
|
assert(true, 'ticket_customer_select')
|
2015-11-29 15:39:56 +00:00
|
|
|
end
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
=begin
|
|
|
|
|
2016-03-13 23:25:05 +00:00
|
|
|
overview_create(
|
2015-11-29 15:39:56 +00:00
|
|
|
browser: browser1,
|
|
|
|
data: {
|
|
|
|
name: name,
|
|
|
|
role: 'Agent',
|
|
|
|
selector: {
|
2015-09-21 20:51:10 +00:00
|
|
|
'Priority': '1 low',
|
|
|
|
},
|
2015-02-22 12:28:34 +00:00
|
|
|
'order::direction' => 'down',
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def overview_create(params)
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('overview_create', params)
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
data = params[:data]
|
|
|
|
|
2016-03-21 19:10:01 +00:00
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: 'a[href="#manage"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: 'a[href="#manage/overviews"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: '#content a[data-type="new"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
2016-03-22 16:40:44 +00:00
|
|
|
sleep 2
|
2015-02-22 12:28:34 +00:00
|
|
|
if data[:name]
|
2016-03-21 12:51:55 +00:00
|
|
|
set(
|
|
|
|
browser: instance,
|
|
|
|
css: '.modal input[name=name]',
|
|
|
|
value: data[:name],
|
|
|
|
mute_log: true,
|
|
|
|
)
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
if data[:role]
|
2016-03-21 12:51:55 +00:00
|
|
|
select(
|
|
|
|
browser: instance,
|
|
|
|
css: '.modal select[name="role_id"]',
|
|
|
|
value: data[:role],
|
|
|
|
mute_log: true,
|
|
|
|
)
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
2015-09-21 20:51:10 +00:00
|
|
|
|
|
|
|
if data[:selector]
|
|
|
|
data[:selector].each {|key, value|
|
2016-03-21 12:51:55 +00:00
|
|
|
select(
|
|
|
|
browser: instance,
|
|
|
|
css: '.modal .ticket_selector .js-attributeSelector select',
|
|
|
|
value: key,
|
|
|
|
mute_log: true,
|
|
|
|
)
|
2016-03-13 23:25:05 +00:00
|
|
|
sleep 0.5
|
2016-03-21 12:51:55 +00:00
|
|
|
select(
|
|
|
|
browser: instance,
|
|
|
|
css: '.modal .ticket_selector .js-value select',
|
|
|
|
value: value,
|
|
|
|
deselect_all: true,
|
|
|
|
mute_log: true,
|
|
|
|
)
|
2015-09-21 20:51:10 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
if data['order::direction']
|
2016-03-21 12:51:55 +00:00
|
|
|
select(
|
|
|
|
browser: instance,
|
|
|
|
css: '.modal select[name="order::direction"]',
|
|
|
|
value: data['order::direction'],
|
|
|
|
mute_log: true,
|
|
|
|
)
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
|
2016-02-25 12:45:46 +00:00
|
|
|
instance.find_elements(css: '.modal button.js-submit')[0].click
|
2015-05-07 09:49:46 +00:00
|
|
|
(1..12).each {
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: 'body')[0]
|
2015-02-22 12:28:34 +00:00
|
|
|
text = element.text
|
|
|
|
if text =~ /#{Regexp.quote(data[:name])}/
|
2015-12-14 23:52:26 +00:00
|
|
|
assert(true, 'overview created')
|
2015-02-22 12:28:34 +00:00
|
|
|
overview = {
|
2015-04-27 13:42:53 +00:00
|
|
|
name: name,
|
2015-02-22 12:28:34 +00:00
|
|
|
}
|
2016-03-03 14:13:06 +00:00
|
|
|
sleep 1
|
2015-02-22 12:28:34 +00:00
|
|
|
return overview
|
|
|
|
end
|
|
|
|
sleep 1
|
|
|
|
}
|
2015-12-14 23:52:26 +00:00
|
|
|
screenshot(browser: instance, comment: 'overview_create_failed')
|
2016-03-01 14:26:46 +00:00
|
|
|
raise 'overview creation failed'
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
|
2016-03-13 23:25:05 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
overview_update(
|
|
|
|
browser: browser1,
|
|
|
|
data: {
|
|
|
|
name: name,
|
|
|
|
role: 'Agent',
|
|
|
|
selector: {
|
|
|
|
'Priority': '1 low',
|
|
|
|
},
|
|
|
|
'order::direction' => 'down',
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def overview_update(params)
|
|
|
|
switch_window_focus(params)
|
|
|
|
log('overview_create', params)
|
|
|
|
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
data = params[:data]
|
|
|
|
|
2016-03-21 19:10:01 +00:00
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: 'a[href="#manage"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: 'a[href="#manage/overviews"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
2016-03-13 23:25:05 +00:00
|
|
|
|
2016-03-14 07:24:28 +00:00
|
|
|
instance.execute_script("$(\"#content td:contains('#{data[:name]}')\").first().click()")
|
2016-03-13 23:25:05 +00:00
|
|
|
sleep 2
|
|
|
|
|
|
|
|
if data[:name]
|
2016-03-21 12:51:55 +00:00
|
|
|
set(
|
|
|
|
browser: instance,
|
|
|
|
css: '.modal input[name=name]',
|
|
|
|
value: data[:name],
|
|
|
|
mute_log: true,
|
|
|
|
)
|
2016-03-13 23:25:05 +00:00
|
|
|
end
|
|
|
|
if data[:role]
|
2016-03-21 12:51:55 +00:00
|
|
|
select(
|
|
|
|
browser: instance,
|
|
|
|
css: '.modal select[name="role_id"]',
|
|
|
|
value: data[:role],
|
|
|
|
mute_log: true,
|
|
|
|
)
|
2016-03-13 23:25:05 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
if data[:selector]
|
|
|
|
data[:selector].each {|key, value|
|
2016-03-21 12:51:55 +00:00
|
|
|
select(
|
|
|
|
browser: instance,
|
|
|
|
css: '.modal .ticket_selector .js-attributeSelector select',
|
|
|
|
value: key,
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
sleep 0.5
|
|
|
|
select(
|
|
|
|
browser: instance,
|
|
|
|
css: '.modal .ticket_selector .js-value select',
|
|
|
|
value: value,
|
|
|
|
deselect_all: true,
|
|
|
|
mute_log: true,
|
|
|
|
)
|
2016-03-13 23:25:05 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
if data['order::direction']
|
2016-03-21 12:51:55 +00:00
|
|
|
select(
|
|
|
|
browser: instance,
|
|
|
|
css: '.modal select[name="order::direction"]',
|
|
|
|
value: data['order::direction'],
|
|
|
|
mute_log: true,
|
|
|
|
)
|
2016-03-13 23:25:05 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
instance.find_elements(css: '.modal button.js-submit')[0].click
|
|
|
|
(1..12).each {
|
|
|
|
element = instance.find_elements(css: 'body')[0]
|
|
|
|
text = element.text
|
|
|
|
if text =~ /#{Regexp.quote(data[:name])}/
|
|
|
|
assert(true, 'overview updated')
|
|
|
|
overview = {
|
|
|
|
name: name,
|
|
|
|
}
|
|
|
|
sleep 1
|
|
|
|
return overview
|
|
|
|
end
|
|
|
|
sleep 1
|
|
|
|
}
|
|
|
|
screenshot(browser: instance, comment: 'overview_update_failed')
|
|
|
|
raise 'overview update failed'
|
|
|
|
end
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
ticket = ticket_create(
|
2015-11-29 15:39:56 +00:00
|
|
|
browser: browser1,
|
|
|
|
data: {
|
|
|
|
customer: 'nico',
|
2016-03-07 03:24:08 +00:00
|
|
|
group: 'Users', # optional / '-NONE-' # if group selection should not be shown
|
2015-11-29 15:39:56 +00:00
|
|
|
priority: '2 normal',
|
2016-04-04 13:54:37 +00:00
|
|
|
state: 'open',
|
2015-11-29 15:39:56 +00:00
|
|
|
title: 'overview #1',
|
|
|
|
body: 'overview #1',
|
2015-02-22 12:28:34 +00:00
|
|
|
},
|
2015-11-29 15:39:56 +00:00
|
|
|
do_not_submit: true,
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
returns (in case of submitted)
|
|
|
|
{
|
2015-11-29 15:39:56 +00:00
|
|
|
id: 123,
|
|
|
|
number: '100001',
|
2016-01-27 21:24:54 +00:00
|
|
|
title: 'overview #1',
|
2015-02-22 12:28:34 +00:00
|
|
|
}
|
|
|
|
|
2016-05-24 07:47:53 +00:00
|
|
|
ticket = ticket_create(
|
|
|
|
browser: browser1,
|
|
|
|
data: {
|
|
|
|
customer: 'nico',
|
|
|
|
group: 'Users', # optional / '-NONE-' # if group selection should not be shown
|
|
|
|
priority: '2 normal',
|
|
|
|
state: 'open',
|
|
|
|
title: 'overview #1',
|
|
|
|
body: 'overview #1',
|
|
|
|
},
|
|
|
|
custom_data_select: {
|
|
|
|
key1: 'some value',
|
|
|
|
},
|
|
|
|
custom_data_input: {
|
|
|
|
key1: 'some value',
|
|
|
|
},
|
|
|
|
disable_group_check: true,
|
|
|
|
)
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
=end
|
|
|
|
|
|
|
|
def ticket_create(params)
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('ticket_create', params)
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
data = params[:data]
|
|
|
|
|
2016-03-21 19:10:01 +00:00
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: 'a[href="#new"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: 'a[href="#ticket/create"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
|
2016-04-30 23:58:15 +00:00
|
|
|
found = false
|
2016-05-27 13:22:00 +00:00
|
|
|
(1..8).each {
|
2016-04-30 23:58:15 +00:00
|
|
|
element = instance.find_elements(css: '.active .newTicket')[0]
|
|
|
|
if element
|
2016-05-01 00:24:31 +00:00
|
|
|
found = true
|
2016-04-30 23:58:15 +00:00
|
|
|
break
|
|
|
|
end
|
|
|
|
sleep 1
|
|
|
|
}
|
|
|
|
if !found
|
2015-12-14 23:52:26 +00:00
|
|
|
screenshot(browser: instance, comment: 'ticket_create_failed')
|
2016-03-01 14:26:46 +00:00
|
|
|
raise 'no ticket create screen found!'
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
if data[:group]
|
2016-03-07 03:24:08 +00:00
|
|
|
if data[:group] == '-NONE-'
|
|
|
|
|
|
|
|
# check if owner selection exists
|
|
|
|
count = instance.find_elements(css: '.active .newTicket select[name="group_id"] option').count
|
|
|
|
assert_equal(0, count, 'owner selection should not be showm')
|
|
|
|
|
|
|
|
# check count of agents, should be only 3 / - selection + master + agent on init screen
|
|
|
|
count = instance.find_elements(css: '.active .newTicket select[name="owner_id"] option').count
|
|
|
|
assert_equal(3, count, 'check if owner selection is - selection + master + agent per default')
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
# check count of agents, should be only 1 / - selection on init screen
|
2016-05-24 07:47:53 +00:00
|
|
|
if !params[:disable_group_check]
|
|
|
|
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')
|
|
|
|
end
|
2016-03-21 12:51:55 +00:00
|
|
|
select(
|
|
|
|
browser: instance,
|
|
|
|
css: '.active .newTicket select[name="group_id"]',
|
|
|
|
value: data[:group],
|
|
|
|
mute_log: true,
|
|
|
|
)
|
2016-03-07 03:24:08 +00:00
|
|
|
sleep 0.2
|
|
|
|
end
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
2015-09-21 20:51:10 +00:00
|
|
|
if data[:priority]
|
2016-03-21 12:51:55 +00:00
|
|
|
select(
|
|
|
|
browser: instance,
|
|
|
|
css: '.active .newTicket select[name="priority_id"]',
|
|
|
|
value: data[:priority],
|
|
|
|
mute_log: true,
|
|
|
|
)
|
2015-09-21 20:51:10 +00:00
|
|
|
end
|
2016-04-04 13:54:37 +00:00
|
|
|
if data[:state]
|
|
|
|
select(
|
|
|
|
browser: instance,
|
|
|
|
css: '.active .newTicket select[name="state_id"]',
|
|
|
|
value: data[:state],
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
end
|
2015-02-22 12:28:34 +00:00
|
|
|
if data[:title]
|
2016-03-21 12:51:55 +00:00
|
|
|
set(
|
|
|
|
browser: instance,
|
|
|
|
css: '.active .newTicket input[name="title"]',
|
|
|
|
value: data[:title],
|
|
|
|
clear: true,
|
|
|
|
mute_log: true,
|
|
|
|
)
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
if data[:body]
|
2016-03-21 12:51:55 +00:00
|
|
|
set(
|
|
|
|
browser: instance,
|
|
|
|
css: '.active .newTicket div[data-name=body]',
|
|
|
|
value: data[:body],
|
|
|
|
clear: true,
|
|
|
|
mute_log: true,
|
|
|
|
)
|
2015-02-28 10:40:23 +00:00
|
|
|
|
|
|
|
# it's not working stable via selenium, use js
|
2016-02-25 12:45:46 +00:00
|
|
|
value = instance.find_elements(css: '.content .newTicket div[data-name=body]')[0].text
|
2015-03-03 13:44:19 +00:00
|
|
|
#puts "V #{value.inspect}"
|
2015-02-28 10:40:23 +00:00
|
|
|
if value != data[:body]
|
2015-12-14 23:52:26 +00:00
|
|
|
body_quoted = quote(data[:body])
|
|
|
|
instance.execute_script("$('.content.active div[data-name=body]').html('#{body_quoted}').trigger('focusout')")
|
2015-02-28 10:40:23 +00:00
|
|
|
end
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
if data[:customer]
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: '.active .newTicket input[name="customer_id_completion"]')[0]
|
2015-02-22 12:28:34 +00:00
|
|
|
element.click
|
|
|
|
element.clear
|
2015-02-28 10:40:23 +00:00
|
|
|
|
|
|
|
# workaround, sometimes focus is not triggered
|
2016-03-14 22:29:39 +00:00
|
|
|
element.send_keys(data[:customer])
|
2016-03-22 12:58:48 +00:00
|
|
|
sleep 2.5
|
2015-02-28 10:40:23 +00:00
|
|
|
|
2015-12-14 23:52:26 +00:00
|
|
|
element.send_keys(:enter)
|
2016-02-25 12:45:46 +00:00
|
|
|
#instance.find_elements(css: '.active .newTicket .recipientList-entry.js-user.is-active')[0].click
|
2016-03-22 12:58:48 +00:00
|
|
|
sleep 0.4
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
2015-02-28 10:40:23 +00:00
|
|
|
|
2016-05-24 07:47:53 +00:00
|
|
|
if params[:custom_data_select]
|
|
|
|
params[:custom_data_select].each {|local_key, local_value|
|
|
|
|
select(
|
|
|
|
browser: instance,
|
|
|
|
css: ".active .newTicket select[name=\"#{local_key}\"]",
|
|
|
|
value: local_value,
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
if params[:custom_data_input]
|
|
|
|
params[:custom_data_input].each {|local_key, local_value|
|
|
|
|
set(
|
|
|
|
browser: instance,
|
|
|
|
css: ".active .newTicket input[name=\"#{local_key}\"]",
|
|
|
|
value: local_value,
|
|
|
|
clear: true,
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2015-02-28 18:51:40 +00:00
|
|
|
if data[:attachment]
|
|
|
|
file_upload(
|
2015-04-27 13:42:53 +00:00
|
|
|
browser: instance,
|
|
|
|
css: '#content .text-1',
|
|
|
|
value: 'some text',
|
2015-02-28 18:51:40 +00:00
|
|
|
)
|
|
|
|
end
|
2015-02-28 10:40:23 +00:00
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
if params[:do_not_submit]
|
2015-12-14 23:52:26 +00:00
|
|
|
assert(true, 'ticket created without submit')
|
2015-02-22 12:28:34 +00:00
|
|
|
return
|
|
|
|
end
|
2016-03-21 19:10:01 +00:00
|
|
|
sleep 0.5
|
2015-12-14 23:52:26 +00:00
|
|
|
#instance.execute_script('$(".content.active .newTicket form").submit();')
|
2016-03-21 19:10:01 +00:00
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: '.active .newTicket button.js-submit',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
sleep 1
|
2015-05-07 09:49:46 +00:00
|
|
|
(1..10).each {
|
2015-02-22 12:28:34 +00:00
|
|
|
if instance.current_url =~ /#{Regexp.quote('#ticket/zoom/')}/
|
2015-12-14 23:52:26 +00:00
|
|
|
assert(true, 'ticket created')
|
2015-03-01 23:16:36 +00:00
|
|
|
sleep 2.5
|
2015-02-22 12:28:34 +00:00
|
|
|
id = instance.current_url
|
2015-12-14 23:52:26 +00:00
|
|
|
id.gsub!(//,)
|
2015-04-27 20:49:17 +00:00
|
|
|
id.gsub!(%r{^.+?/(\d+)$}, '\\1')
|
2015-02-22 12:28:34 +00:00
|
|
|
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: '.active .ticketZoom-header .ticket-number')[0]
|
2015-03-01 23:16:36 +00:00
|
|
|
if element
|
|
|
|
number = element.text
|
|
|
|
ticket = {
|
2015-04-27 13:42:53 +00:00
|
|
|
id: id,
|
|
|
|
number: number,
|
2016-01-27 21:24:54 +00:00
|
|
|
title: data[:title],
|
2015-03-01 23:16:36 +00:00
|
|
|
}
|
2015-04-14 20:25:16 +00:00
|
|
|
sleep 3 # wait until notify is gone
|
2015-12-14 23:52:26 +00:00
|
|
|
screenshot(browser: instance, comment: 'ticket_create_ok')
|
2015-03-01 23:16:36 +00:00
|
|
|
return ticket
|
|
|
|
end
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
2015-03-01 23:16:36 +00:00
|
|
|
sleep 1
|
2015-02-22 12:28:34 +00:00
|
|
|
}
|
2015-12-14 23:52:26 +00:00
|
|
|
screenshot(browser: instance, comment: 'ticket_create_failed')
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "ticket creation failed, can't get zoom url (current url is '#{instance.current_url}')"
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
ticket_update(
|
2015-11-29 15:39:56 +00:00
|
|
|
browser: browser1,
|
|
|
|
data: {
|
|
|
|
title: '',
|
|
|
|
customer: 'some_customer@example.com',
|
|
|
|
body: 'some body',
|
2016-03-07 03:24:08 +00:00
|
|
|
group: 'some group', # optional
|
2015-11-29 15:39:56 +00:00
|
|
|
priority: '1 low',
|
|
|
|
state: 'closed',
|
2015-02-22 12:28:34 +00:00
|
|
|
},
|
2015-11-29 15:39:56 +00:00
|
|
|
do_not_submit: true,
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
2016-05-24 07:47:53 +00:00
|
|
|
ticket_update(
|
|
|
|
browser: browser1,
|
|
|
|
data: {
|
|
|
|
title: '',
|
|
|
|
customer: 'some_customer@example.com',
|
|
|
|
body: 'some body',
|
|
|
|
group: 'some group', # optional
|
|
|
|
priority: '1 low',
|
|
|
|
state: 'closed',
|
|
|
|
},
|
|
|
|
custom_data_select: {
|
|
|
|
key1: 'some value',
|
|
|
|
},
|
|
|
|
custom_data_input: {
|
|
|
|
key1: 'some value',
|
|
|
|
},
|
|
|
|
do_not_submit: true,
|
|
|
|
)
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
=end
|
|
|
|
|
|
|
|
def ticket_update(params)
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('ticket_update', params)
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
data = params[:data]
|
|
|
|
|
2015-02-23 15:35:48 +00:00
|
|
|
if data[:title]
|
2016-05-23 13:23:18 +00:00
|
|
|
#element = instance.find_elements(:css => '.content.active .ticketZoom-header .js-objectTitle')[0]
|
2015-02-23 15:35:48 +00:00
|
|
|
#element.clear
|
|
|
|
#sleep 0.5
|
2016-05-23 13:23:18 +00:00
|
|
|
#element = instance.find_elements(:css => '.content.active .ticketZoom-header .js-objectTitle')[0]
|
2015-12-14 23:52:26 +00:00
|
|
|
#element.send_keys(data[:title])
|
2015-02-23 15:35:48 +00:00
|
|
|
#sleep 0.5
|
2015-12-14 23:52:26 +00:00
|
|
|
#element.send_keys(:tab)
|
2015-02-23 15:35:48 +00:00
|
|
|
|
2016-05-23 13:23:18 +00:00
|
|
|
instance.execute_script('$(".content.active .ticketZoom-header .js-objectTitle").focus()')
|
|
|
|
instance.execute_script('$(".content.active .ticketZoom-header .js-objectTitle").text("' + data[:title] + '")')
|
|
|
|
instance.execute_script('$(".content.active .ticketZoom-header .js-objectTitle").blur()')
|
|
|
|
instance.execute_script('$(".content.active .ticketZoom-header .js-objectTitle").trigger("blur")')
|
2015-04-27 20:49:17 +00:00
|
|
|
# {
|
|
|
|
# :where => :instance2,
|
|
|
|
# :execute => 'sendkey',
|
2016-05-23 13:23:18 +00:00
|
|
|
# :css => '.content.active .ticketZoom-header .js-objectTitle',
|
2015-04-27 20:49:17 +00:00
|
|
|
# :value => 'TTT',
|
|
|
|
# },
|
|
|
|
# {
|
|
|
|
# :where => :instance2,
|
|
|
|
# :execute => 'sendkey',
|
2016-05-23 13:23:18 +00:00
|
|
|
# :css => '.content.active .ticketZoom-header .js-objectTitle',
|
2015-04-27 20:49:17 +00:00
|
|
|
# :value => :tab,
|
|
|
|
# },
|
2015-03-08 21:34:14 +00:00
|
|
|
end
|
|
|
|
if data[:customer]
|
|
|
|
|
|
|
|
# select tab
|
2015-12-14 23:52:26 +00:00
|
|
|
click(browser: instance, css: '.active .tabsSidebar-tab[data-tab="customer"]')
|
2015-03-08 21:34:14 +00:00
|
|
|
|
2015-12-14 23:52:26 +00:00
|
|
|
click(browser: instance, css: '.active div[data-tab="customer"] .js-actions .icon-arrow-down')
|
|
|
|
click(browser: instance, css: '.active div[data-tab="customer"] .js-actions [data-type="customer-change"]')
|
2015-03-08 21:34:14 +00:00
|
|
|
watch_for(
|
2015-04-27 13:42:53 +00:00
|
|
|
browser: instance,
|
|
|
|
css: '.modal',
|
|
|
|
value: 'change',
|
2015-03-08 21:34:14 +00:00
|
|
|
)
|
|
|
|
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: '.modal input[name="customer_id_completion"]')[0]
|
2015-03-08 21:34:14 +00:00
|
|
|
element.click
|
|
|
|
element.clear
|
|
|
|
|
|
|
|
# workaround, sometimes focus is not triggered
|
2015-12-14 23:52:26 +00:00
|
|
|
element.send_keys(data[:customer])
|
2016-03-22 12:58:48 +00:00
|
|
|
sleep 2.5
|
2015-03-08 21:34:14 +00:00
|
|
|
|
2015-12-14 23:52:26 +00:00
|
|
|
element.send_keys(:enter)
|
2016-02-25 12:45:46 +00:00
|
|
|
#instance.find_elements(css: '.modal .user_autocompletion .recipientList-entry.js-user.is-active')[0].click
|
2016-03-22 12:58:48 +00:00
|
|
|
sleep 0.2
|
2015-03-08 21:34:14 +00:00
|
|
|
|
2015-12-14 23:52:26 +00:00
|
|
|
click(browser: instance, css: '.modal .js-submit')
|
2015-03-08 21:34:14 +00:00
|
|
|
|
|
|
|
watch_for_disappear(
|
2015-04-27 13:42:53 +00:00
|
|
|
browser: instance,
|
|
|
|
css: '.modal',
|
2015-03-08 21:34:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
watch_for(
|
2015-04-27 13:42:53 +00:00
|
|
|
browser: instance,
|
|
|
|
css: '.active .tabsSidebar',
|
|
|
|
value: data[:customer],
|
2015-03-08 21:34:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# select tab
|
2015-12-14 23:52:26 +00:00
|
|
|
click(browser: instance, css: '.active .tabsSidebar-tab[data-tab="ticket"]')
|
2015-03-08 21:34:14 +00:00
|
|
|
|
2015-02-23 15:35:48 +00:00
|
|
|
end
|
|
|
|
if data[:body]
|
2016-03-21 12:51:55 +00:00
|
|
|
set(
|
|
|
|
browser: instance,
|
|
|
|
css: '.content.active div[data-name=body]',
|
|
|
|
value: data[:body],
|
2016-03-21 13:39:18 +00:00
|
|
|
no_click: true,
|
2016-03-21 12:51:55 +00:00
|
|
|
mute_log: true,
|
|
|
|
)
|
2015-02-28 10:40:23 +00:00
|
|
|
|
|
|
|
# it's not working stable via selenium, use js
|
2016-02-25 12:45:46 +00:00
|
|
|
value = instance.find_elements(css: '.content.active div[data-name=body]')[0].text
|
2015-02-28 10:40:23 +00:00
|
|
|
if value != data[:body]
|
2015-12-14 23:52:26 +00:00
|
|
|
body_quoted = quote(data[:body])
|
|
|
|
instance.execute_script("$('.content.active div[data-name=body]').html('#{body_quoted}').trigger('focusout')")
|
2015-02-28 10:40:23 +00:00
|
|
|
end
|
|
|
|
|
2015-02-23 15:35:48 +00:00
|
|
|
end
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
if data[:group]
|
2016-03-07 03:24:08 +00:00
|
|
|
if data[:group] == '-NONE-'
|
|
|
|
|
|
|
|
# check if owner selection exists
|
|
|
|
count = instance.find_elements(css: '.active .sidebar select[name="group_id"] option').count
|
|
|
|
assert_equal(0, count, 'owner selection should not be showm')
|
|
|
|
|
|
|
|
# check count of agents, should be only 3 / - selection + master + agent on init screen
|
|
|
|
count = instance.find_elements(css: '.active .sidebar select[name="owner_id"] option').count
|
|
|
|
assert_equal(3, count, 'check if owner selection is - selection + master + agent per default')
|
|
|
|
|
|
|
|
else
|
2016-03-21 12:51:55 +00:00
|
|
|
select(
|
|
|
|
browser: instance,
|
|
|
|
css: '.active .sidebar select[name="group_id"]',
|
|
|
|
value: data[:group],
|
|
|
|
mute_log: true,
|
|
|
|
)
|
2016-03-07 03:24:08 +00:00
|
|
|
sleep 0.2
|
|
|
|
end
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
|
2015-09-21 20:51:10 +00:00
|
|
|
if data[:priority]
|
2016-03-21 12:51:55 +00:00
|
|
|
select(
|
|
|
|
browser: instance,
|
|
|
|
css: '.active .sidebar select[name="priority_id"]',
|
|
|
|
value: data[:priority],
|
|
|
|
mute_log: true,
|
|
|
|
)
|
2015-09-21 20:51:10 +00:00
|
|
|
end
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
if data[:state]
|
2016-03-21 12:51:55 +00:00
|
|
|
select(
|
|
|
|
browser: instance,
|
|
|
|
css: '.active .sidebar select[name="state_id"]',
|
|
|
|
value: data[:state],
|
|
|
|
mute_log: true,
|
|
|
|
)
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
|
2016-05-24 07:47:53 +00:00
|
|
|
if params[:custom_data_select]
|
|
|
|
params[:custom_data_select].each {|local_key, local_value|
|
|
|
|
select(
|
|
|
|
browser: instance,
|
|
|
|
css: ".active .sidebar select[name=\"#{local_key}\"]",
|
|
|
|
value: local_value,
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
if params[:custom_data_input]
|
|
|
|
params[:custom_data_input].each {|local_key, local_value|
|
|
|
|
set(
|
|
|
|
browser: instance,
|
|
|
|
css: ".active .sidebar input[name=\"#{local_key}\"]",
|
|
|
|
value: local_value,
|
|
|
|
clear: true,
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
if data[:state] || data[:group] || data[:body] || !params[:custom_data_select].empty? || !params[:custom_data_input].empty?
|
2015-03-08 21:34:14 +00:00
|
|
|
found = nil
|
2015-06-23 13:47:18 +00:00
|
|
|
(1..10).each {
|
2015-07-03 17:36:13 +00:00
|
|
|
|
2015-07-16 15:19:46 +00:00
|
|
|
break if found
|
2015-07-03 17:36:13 +00:00
|
|
|
|
|
|
|
begin
|
2016-02-25 12:45:46 +00:00
|
|
|
text = instance.find_elements(css: '.content.active .js-reset')[0].text
|
2015-07-03 17:36:13 +00:00
|
|
|
if text =~ /(Discard your unsaved changes.|Verwerfen der)/
|
|
|
|
found = true
|
2015-02-22 22:51:44 +00:00
|
|
|
end
|
2015-07-03 17:36:13 +00:00
|
|
|
rescue
|
|
|
|
# try again
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
2015-07-03 17:36:13 +00:00
|
|
|
sleep 1
|
2015-03-08 21:34:14 +00:00
|
|
|
}
|
|
|
|
if !found
|
2015-12-14 23:52:26 +00:00
|
|
|
screenshot(browser: instance, comment: 'ticket_update_discard_message_failed')
|
2015-07-16 15:19:46 +00:00
|
|
|
|
2016-03-01 14:26:46 +00:00
|
|
|
raise 'no discard message found'
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-11-06 01:08:06 +00:00
|
|
|
task_type(
|
|
|
|
browser: instance,
|
|
|
|
type: 'stayOnTab',
|
|
|
|
)
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
if params[:do_not_submit]
|
2015-12-14 23:52:26 +00:00
|
|
|
assert(true, 'ticket updated without submit')
|
2015-02-22 12:28:34 +00:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2016-02-25 12:45:46 +00:00
|
|
|
instance.find_elements(css: '.content.active .js-submit')[0].click
|
2015-02-22 12:28:34 +00:00
|
|
|
|
2015-05-07 09:49:46 +00:00
|
|
|
(1..10).each {
|
2015-02-24 00:11:10 +00:00
|
|
|
begin
|
2016-02-25 12:45:46 +00:00
|
|
|
text = instance.find_elements(css: '.content.active .js-reset')[0].text
|
2015-02-24 00:11:10 +00:00
|
|
|
if !text || text.empty?
|
2015-12-14 23:52:26 +00:00
|
|
|
screenshot(browser: instance, comment: 'ticket_update_ok')
|
2016-03-03 16:42:19 +00:00
|
|
|
sleep 1
|
2015-02-24 00:11:10 +00:00
|
|
|
return true
|
|
|
|
end
|
2015-04-28 20:44:31 +00:00
|
|
|
rescue
|
|
|
|
# try again
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
sleep 1
|
|
|
|
}
|
2015-12-14 23:52:26 +00:00
|
|
|
screenshot(browser: instance, comment: 'ticket_update_failed')
|
2016-03-01 14:26:46 +00:00
|
|
|
raise 'unable to update ticket'
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
|
2015-02-28 18:51:40 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
ticket_verify(
|
2015-11-29 15:39:56 +00:00
|
|
|
browser: browser1,
|
|
|
|
data: {
|
|
|
|
title: 'some title',
|
|
|
|
body: 'some body',
|
|
|
|
## group: 'some group',
|
|
|
|
## state: 'closed',
|
2015-02-28 18:51:40 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def ticket_verify(params)
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('ticket_verify', params)
|
|
|
|
|
2015-02-28 18:51:40 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
data = params[:data]
|
|
|
|
|
|
|
|
if data[:title]
|
2016-05-23 13:23:18 +00:00
|
|
|
title = instance.find_elements(css: '.content.active .ticketZoom-header .js-objectTitle')[0].text.strip
|
2015-02-28 18:51:40 +00:00
|
|
|
if title =~ /#{data[:title]}/i
|
2015-12-14 23:52:26 +00:00
|
|
|
assert(true, "matching '#{data[:title]}' in title '#{title}'")
|
2015-02-28 18:51:40 +00:00
|
|
|
else
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "not matching '#{data[:title]}' in title '#{title}'"
|
2015-02-28 18:51:40 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if data[:body]
|
2016-02-25 12:45:46 +00:00
|
|
|
body = instance.find_elements(css: '.content.active [data-name="body"]')[0].text.strip
|
2015-02-28 18:51:40 +00:00
|
|
|
if body =~ /#{data[:body]}/i
|
2015-12-14 23:52:26 +00:00
|
|
|
assert(true, "matching '#{data[:body]}' in body '#{body}'")
|
2015-02-28 18:51:40 +00:00
|
|
|
else
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "not matching '#{data[:body]}' in body '#{body}'"
|
2015-02-28 18:51:40 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
ticket_open_by_overview(
|
2015-11-29 15:39:56 +00:00
|
|
|
browser: browser2,
|
|
|
|
number: ticket1[:number],
|
|
|
|
link: "#ticket/view/#{name}",
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def ticket_open_by_overview(params)
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('ticket_open_by_overview', params)
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
2016-02-25 12:45:46 +00:00
|
|
|
instance.find_elements(css: '.js-overviewsMenuItem')[0].click
|
2015-02-22 12:28:34 +00:00
|
|
|
sleep 1
|
2015-11-05 12:34:22 +00:00
|
|
|
execute(
|
|
|
|
browser: instance,
|
|
|
|
js: '$(".content.active .sidebar").css("display", "block")',
|
|
|
|
)
|
2016-02-25 12:45:46 +00:00
|
|
|
instance.find_elements(css: ".content.active .sidebar a[href=\"#{params[:link]}\"]")[0].click
|
2015-02-22 12:28:34 +00:00
|
|
|
sleep 1
|
2015-11-17 23:53:19 +00:00
|
|
|
execute(
|
|
|
|
browser: instance,
|
|
|
|
js: '$(".content.active .sidebar").css("display", "none")',
|
|
|
|
)
|
2016-02-25 12:45:46 +00:00
|
|
|
instance.find_elements(partial_link_text: params[:number])[0].click
|
2015-02-22 12:28:34 +00:00
|
|
|
sleep 1
|
2016-02-25 12:45:46 +00:00
|
|
|
number = instance.find_elements(css: '.active .ticketZoom-header .ticket-number')[0].text
|
2015-02-22 12:28:34 +00:00
|
|
|
if number !~ /#{params[:number]}/
|
2015-12-14 23:52:26 +00:00
|
|
|
screenshot(browser: instance, comment: 'ticket_open_by_overview_failed')
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "unable to search/find ticket #{params[:number]}!"
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
2015-02-28 10:40:23 +00:00
|
|
|
sleep 1
|
2015-12-14 23:52:26 +00:00
|
|
|
assert(true, "ticket #{params[:number]} found")
|
2015-02-28 10:40:23 +00:00
|
|
|
true
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
ticket_open_by_search(
|
2015-11-29 15:39:56 +00:00
|
|
|
browser: browser2,
|
|
|
|
number: ticket1[:number],
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def ticket_open_by_search(params)
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('ticket_open_by_search', params)
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
|
|
|
# search by number
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: '#global-search')[0]
|
2015-02-22 12:28:34 +00:00
|
|
|
element.click
|
|
|
|
element.clear
|
2015-12-14 23:52:26 +00:00
|
|
|
element.send_keys(params[:number])
|
2015-02-22 12:28:34 +00:00
|
|
|
sleep 3
|
|
|
|
|
2016-03-15 10:24:42 +00:00
|
|
|
empty_search(browser: instance)
|
2015-02-22 12:28:34 +00:00
|
|
|
|
|
|
|
# search by number again
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: '#global-search')[0]
|
2015-02-22 12:28:34 +00:00
|
|
|
element.click
|
|
|
|
element.clear
|
2015-12-14 23:52:26 +00:00
|
|
|
element.send_keys(params[:number])
|
2015-02-22 12:28:34 +00:00
|
|
|
sleep 1
|
|
|
|
|
|
|
|
# open ticket
|
2016-02-25 12:45:46 +00:00
|
|
|
#instance.find_element(partial_link_text: params[:number] } ).click
|
2015-12-14 23:52:26 +00:00
|
|
|
instance.execute_script("$(\"#global-search-result a:contains('#{params[:value]}') .nav-tab-icon\").click()")
|
2016-03-15 15:01:28 +00:00
|
|
|
sleep 1
|
2016-02-25 12:45:46 +00:00
|
|
|
number = instance.find_elements(css: '.active .ticketZoom-header .ticket-number')[0].text
|
2015-02-22 12:28:34 +00:00
|
|
|
if number !~ /#{params[:number]}/
|
2015-12-14 23:52:26 +00:00
|
|
|
screenshot(browser: instance, comment: 'ticket_open_by_search_failed')
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "unable to search/find ticket #{params[:number]}!"
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
2015-02-28 10:40:23 +00:00
|
|
|
sleep 1
|
|
|
|
true
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
|
2016-01-13 23:33:34 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
ticket_open_by_title(
|
|
|
|
browser: browser2,
|
|
|
|
title: ticket1[:title],
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def ticket_open_by_title(params)
|
|
|
|
switch_window_focus(params)
|
|
|
|
log('ticket_open_by_title', params)
|
|
|
|
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
|
|
|
# search by number
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: '#global-search')[0]
|
2016-01-13 23:33:34 +00:00
|
|
|
element.click
|
|
|
|
element.clear
|
|
|
|
element.send_keys(params[:title])
|
|
|
|
sleep 3
|
|
|
|
|
|
|
|
# open ticket
|
2016-02-25 12:45:46 +00:00
|
|
|
#instance.find_element(partial_link_text: params[:title] } ).click
|
2016-01-13 23:33:34 +00:00
|
|
|
instance.execute_script("$(\"#global-search-result a:contains('#{params[:title]}') .nav-tab-icon\").click()")
|
2016-03-15 15:01:28 +00:00
|
|
|
sleep 1
|
2016-05-23 13:23:18 +00:00
|
|
|
title = instance.find_elements(css: '.active .ticketZoom-header .js-objectTitle')[0].text
|
2016-01-13 23:33:34 +00:00
|
|
|
if title !~ /#{params[:title]}/
|
|
|
|
screenshot(browser: instance, comment: 'ticket_open_by_title_failed')
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "unable to search/find ticket #{params[:title]}!"
|
2016-01-13 23:33:34 +00:00
|
|
|
end
|
|
|
|
sleep 1
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
overview_count = overview_counter(
|
2015-11-29 15:39:56 +00:00
|
|
|
browser: browser2,
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
returns
|
|
|
|
{
|
|
|
|
'#ticket/view/all_unassigned' => 42,
|
|
|
|
}
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def overview_counter(params = {})
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('overview_counter', params)
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
2016-02-25 12:45:46 +00:00
|
|
|
instance.find_elements(css: '.js-overviewsMenuItem')[0].click
|
2015-02-22 12:28:34 +00:00
|
|
|
sleep 2
|
2015-11-05 12:34:22 +00:00
|
|
|
|
|
|
|
execute(
|
|
|
|
browser: instance,
|
|
|
|
js: '$(".content.active .sidebar").css("display", "block")',
|
|
|
|
)
|
2015-11-17 09:03:51 +00:00
|
|
|
#execute(
|
|
|
|
# browser: instance,
|
|
|
|
# js: '$(".content.active .overview-header").css("display", "none")',
|
|
|
|
#)
|
2015-11-05 12:34:22 +00:00
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
overviews = {}
|
2016-02-25 12:45:46 +00:00
|
|
|
instance.find_elements(css: '.content.active .sidebar a[href]').each {|element|
|
2015-02-22 12:28:34 +00:00
|
|
|
url = element.attribute('href')
|
2015-04-27 20:49:17 +00:00
|
|
|
url.gsub!(%r{(http|https)://.+?/(.+?)$}, '\\2')
|
2015-02-22 12:28:34 +00:00
|
|
|
overviews[url] = 0
|
|
|
|
#puts url.inspect
|
|
|
|
#puts element.inspect
|
|
|
|
}
|
2015-05-07 09:49:46 +00:00
|
|
|
overviews.each {|url, _value|
|
2016-02-25 12:45:46 +00:00
|
|
|
count = instance.find_elements(css: ".content.active .sidebar a[href=\"#{url}\"] .badge")[0].text
|
2015-02-22 12:28:34 +00:00
|
|
|
overviews[url] = count.to_i
|
|
|
|
}
|
2015-11-05 12:34:22 +00:00
|
|
|
log('overview_counter', overviews)
|
2015-02-22 12:28:34 +00:00
|
|
|
overviews
|
|
|
|
end
|
|
|
|
|
2015-02-23 13:49:40 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
organization_open_by_search(
|
2015-11-29 15:39:56 +00:00
|
|
|
browser: browser2,
|
|
|
|
value: 'some value',
|
2015-02-23 13:49:40 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def organization_open_by_search(params = {})
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('organization_open_by_search', params)
|
|
|
|
|
2015-02-23 13:49:40 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: '#global-search')[0]
|
2015-02-23 13:49:40 +00:00
|
|
|
|
|
|
|
element.click
|
|
|
|
element.clear
|
2015-12-14 23:52:26 +00:00
|
|
|
element.send_keys(params[:value])
|
2015-02-23 13:49:40 +00:00
|
|
|
sleep 3
|
2016-03-15 10:24:42 +00:00
|
|
|
|
|
|
|
empty_search(browser: instance)
|
|
|
|
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: '#global-search')[0]
|
2015-02-23 13:49:40 +00:00
|
|
|
element.click
|
|
|
|
element.clear
|
2015-12-14 23:52:26 +00:00
|
|
|
element.send_keys(params[:value])
|
2015-02-23 13:49:40 +00:00
|
|
|
sleep 2
|
2016-02-25 12:45:46 +00:00
|
|
|
#instance.find_element(partial_link_text: params[:value] } ).click
|
2015-12-14 23:52:26 +00:00
|
|
|
instance.execute_script("$(\"#global-search-result a:contains('#{params[:value]}') .nav-tab-icon\").click()")
|
2016-03-15 15:01:28 +00:00
|
|
|
sleep 1
|
2016-02-25 12:45:46 +00:00
|
|
|
name = instance.find_elements(css: '.active h1')[0].text
|
2015-02-23 13:49:40 +00:00
|
|
|
if name !~ /#{params[:value]}/
|
2015-12-14 23:52:26 +00:00
|
|
|
screenshot(browser: instance, comment: 'organization_open_by_search_failed')
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "unable to search/find org #{params[:value]}!"
|
2015-02-23 13:49:40 +00:00
|
|
|
end
|
2015-12-14 23:52:26 +00:00
|
|
|
assert(true, "org #{params[:value]} found")
|
2015-02-28 10:40:23 +00:00
|
|
|
sleep 2
|
2015-02-23 13:49:40 +00:00
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2015-02-23 13:02:46 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
user_open_by_search(
|
2015-11-29 15:39:56 +00:00
|
|
|
browser: browser2,
|
|
|
|
value: 'some value',
|
2015-02-23 13:02:46 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def user_open_by_search(params = {})
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('user_open_by_search', params)
|
|
|
|
|
2015-02-23 13:02:46 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: '#global-search')[0]
|
2015-02-23 13:02:46 +00:00
|
|
|
element.click
|
|
|
|
element.clear
|
2015-12-14 23:52:26 +00:00
|
|
|
element.send_keys(params[:value])
|
2015-02-23 13:02:46 +00:00
|
|
|
sleep 3
|
2016-02-25 12:45:46 +00:00
|
|
|
#instance.find_element(partial_link_text: params[:value]).click
|
2015-12-14 23:52:26 +00:00
|
|
|
instance.execute_script("$(\"#global-search-result a:contains('#{params[:value]}') .nav-tab-icon\").click()")
|
2016-03-15 15:01:28 +00:00
|
|
|
sleep 1
|
2016-02-25 12:45:46 +00:00
|
|
|
name = instance.find_elements(css: '.active h1')[0].text
|
2015-02-23 13:02:46 +00:00
|
|
|
if name !~ /#{params[:value]}/
|
2015-12-14 23:52:26 +00:00
|
|
|
screenshot(browser: instance, comment: 'user_open_by_search_failed')
|
2016-03-01 14:26:46 +00:00
|
|
|
raise "unable to search/find user #{params[:value]}!"
|
2015-02-23 13:02:46 +00:00
|
|
|
end
|
2015-12-14 23:52:26 +00:00
|
|
|
assert(true, "user #{params[:term]} found")
|
2015-02-28 10:40:23 +00:00
|
|
|
sleep 2
|
2015-02-23 13:02:46 +00:00
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
user_create(
|
2015-11-29 15:39:56 +00:00
|
|
|
browser: browser2,
|
|
|
|
data: {
|
2015-11-27 19:58:27 +00:00
|
|
|
#login: 'some login' + random,
|
|
|
|
firstname: 'Manage Firstname' + random,
|
|
|
|
lastname: 'Manage Lastname' + random,
|
|
|
|
email: user_email,
|
|
|
|
password: 'some-pass',
|
2015-02-23 13:02:46 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def user_create(params = {})
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('user_create', params)
|
|
|
|
|
2015-02-23 13:02:46 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
data = params[:data]
|
|
|
|
|
2016-03-21 19:10:01 +00:00
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: 'a[href="#manage"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: 'a[href="#manage/users"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: 'a[data-type="new"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
|
2015-02-23 13:02:46 +00:00
|
|
|
sleep 2
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: '.modal input[name=firstname]')[0]
|
2015-02-23 13:02:46 +00:00
|
|
|
element.clear
|
2015-12-14 23:52:26 +00:00
|
|
|
element.send_keys(data[:firstname])
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: '.modal input[name=lastname]')[0]
|
2015-02-23 13:02:46 +00:00
|
|
|
element.clear
|
2015-12-14 23:52:26 +00:00
|
|
|
element.send_keys(data[:lastname])
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: '.modal input[name=email]')[0]
|
2015-02-23 13:02:46 +00:00
|
|
|
element.clear
|
2015-12-14 23:52:26 +00:00
|
|
|
element.send_keys(data[:email])
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: '.modal input[name=password]')[0]
|
2015-02-23 13:02:46 +00:00
|
|
|
element.clear
|
2015-12-14 23:52:26 +00:00
|
|
|
element.send_keys(data[:password])
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: '.modal input[name=password_confirm]')[0]
|
2015-02-23 13:02:46 +00:00
|
|
|
element.clear
|
2015-12-14 23:52:26 +00:00
|
|
|
element.send_keys(data[:password])
|
2016-03-14 20:03:51 +00:00
|
|
|
check(
|
|
|
|
browser: instance,
|
|
|
|
css: '.modal input[name=role_ids][value=3]',
|
|
|
|
)
|
2016-02-25 12:45:46 +00:00
|
|
|
instance.find_elements(css: '.modal button.js-submit')[0].click
|
2015-11-27 19:58:27 +00:00
|
|
|
sleep 3.5
|
2015-02-23 13:02:46 +00:00
|
|
|
set(
|
2015-04-27 13:42:53 +00:00
|
|
|
browser: instance,
|
|
|
|
css: '.content .js-search',
|
|
|
|
value: data[:email],
|
2015-02-23 13:02:46 +00:00
|
|
|
)
|
|
|
|
watch_for(
|
2015-04-27 13:42:53 +00:00
|
|
|
browser: instance,
|
|
|
|
css: 'body',
|
|
|
|
value: data[:lastname],
|
2015-02-23 13:02:46 +00:00
|
|
|
)
|
|
|
|
|
2015-12-14 23:52:26 +00:00
|
|
|
assert(true, 'user created')
|
2015-02-23 13:02:46 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
sla_create(
|
2015-11-29 15:39:56 +00:00
|
|
|
browser: browser2,
|
|
|
|
data: {
|
|
|
|
name: 'some sla' + random,
|
|
|
|
first_response_time_in_text: 61
|
2015-02-23 13:02:46 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def sla_create(params = {})
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('sla_create', params)
|
|
|
|
|
2015-02-23 13:02:46 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
data = params[:data]
|
|
|
|
|
2016-03-21 19:10:01 +00:00
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: 'a[href="#manage"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: 'a[href="#manage/slas"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: 'a.js-new',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
|
2015-02-23 13:02:46 +00:00
|
|
|
sleep 2
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: '.modal input[name=name]')[0]
|
2015-02-23 13:02:46 +00:00
|
|
|
element.clear
|
2015-12-14 23:52:26 +00:00
|
|
|
element.send_keys(data[:name])
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: '.modal input[name=first_response_time_in_text]')[0]
|
2015-02-23 13:02:46 +00:00
|
|
|
element.clear
|
2015-12-14 23:52:26 +00:00
|
|
|
element.send_keys(data[:first_response_time_in_text])
|
2016-02-25 12:45:46 +00:00
|
|
|
instance.find_elements(css: '.modal button.js-submit')[0].click
|
2015-05-07 09:49:46 +00:00
|
|
|
(1..8).each {
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: 'body')[0]
|
2015-02-23 13:02:46 +00:00
|
|
|
text = element.text
|
|
|
|
if text =~ /#{Regexp.quote(data[:name])}/
|
2015-12-14 23:52:26 +00:00
|
|
|
assert(true, 'sla created')
|
2016-03-03 14:13:06 +00:00
|
|
|
sleep 1
|
2015-02-23 13:02:46 +00:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
sleep 1
|
|
|
|
}
|
2015-12-14 23:52:26 +00:00
|
|
|
screenshot(browser: instance, comment: 'sla_create_failed')
|
2016-03-01 14:26:46 +00:00
|
|
|
raise 'sla creation failed'
|
2015-02-23 13:02:46 +00:00
|
|
|
end
|
|
|
|
|
2015-02-23 22:37:00 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
text_module_create(
|
2015-11-29 15:39:56 +00:00
|
|
|
browser: browser2,
|
|
|
|
data: {
|
|
|
|
name: 'some sla' + random,
|
|
|
|
keywords: 'some keywords',
|
|
|
|
content: 'some content',
|
2015-02-23 22:37:00 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def text_module_create(params = {})
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('text_module_create', params)
|
|
|
|
|
2015-02-23 22:37:00 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
data = params[:data]
|
|
|
|
|
2016-03-21 19:10:01 +00:00
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: 'a[href="#manage"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: 'a[href="#manage/text_modules"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: 'a[data-type="new"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
|
2015-02-23 22:37:00 +00:00
|
|
|
sleep 2
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: '.modal input[name=name]')[0]
|
2015-02-23 22:37:00 +00:00
|
|
|
element.clear
|
2015-12-14 23:52:26 +00:00
|
|
|
element.send_keys(data[:name])
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: '.modal input[name=keywords]')[0]
|
2015-02-23 22:37:00 +00:00
|
|
|
element.clear
|
2015-12-14 23:52:26 +00:00
|
|
|
element.send_keys(data[:keywords])
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: '.modal [data-name=content]')[0]
|
2015-02-23 22:37:00 +00:00
|
|
|
element.clear
|
2015-12-14 23:52:26 +00:00
|
|
|
element.send_keys(data[:content])
|
2016-02-25 12:45:46 +00:00
|
|
|
instance.find_elements(css: '.modal button.js-submit')[0].click
|
2015-05-07 09:49:46 +00:00
|
|
|
(1..8).each {
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: 'body')[0]
|
2015-02-23 22:37:00 +00:00
|
|
|
text = element.text
|
|
|
|
if text =~ /#{Regexp.quote(data[:name])}/
|
2015-12-14 23:52:26 +00:00
|
|
|
assert(true, 'text module created')
|
2016-03-03 14:13:06 +00:00
|
|
|
sleep 1
|
2015-02-23 22:37:00 +00:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
sleep 1
|
|
|
|
}
|
2015-12-14 23:52:26 +00:00
|
|
|
screenshot(browser: instance, comment: 'text_module_create_failed')
|
2016-03-01 14:26:46 +00:00
|
|
|
raise 'text module creation failed'
|
2015-02-23 22:37:00 +00:00
|
|
|
end
|
|
|
|
|
2015-03-01 23:16:36 +00:00
|
|
|
=begin
|
2012-12-14 10:14:48 +00:00
|
|
|
|
2015-03-01 23:16:36 +00:00
|
|
|
signature_create(
|
2015-11-29 15:39:56 +00:00
|
|
|
browser: browser2,
|
|
|
|
data: {
|
|
|
|
name: 'some sla' + random,
|
|
|
|
body: 'some body',
|
2015-03-01 23:16:36 +00:00
|
|
|
},
|
|
|
|
)
|
2014-12-09 19:10:38 +00:00
|
|
|
|
2015-03-01 23:16:36 +00:00
|
|
|
=end
|
2014-12-09 19:10:38 +00:00
|
|
|
|
2015-03-01 23:16:36 +00:00
|
|
|
def signature_create(params = {})
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('signature_create', params)
|
|
|
|
|
2015-03-01 23:16:36 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
data = params[:data]
|
2012-12-14 12:16:04 +00:00
|
|
|
|
2016-03-21 19:10:01 +00:00
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: 'a[href="#manage"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: 'a[href="#channels/email"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: 'a[href="#c-signature"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
sleep 4
|
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: '#content #c-signature a[data-type="new"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
|
2015-03-01 23:16:36 +00:00
|
|
|
sleep 2
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: '.modal input[name=name]')[0]
|
2015-03-01 23:16:36 +00:00
|
|
|
element.clear
|
2015-11-30 12:13:27 +00:00
|
|
|
element.send_keys(data[:name])
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: '.modal [data-name=body]')[0]
|
2015-03-01 23:16:36 +00:00
|
|
|
element.clear
|
2015-11-30 12:13:27 +00:00
|
|
|
element.send_keys(data[:body])
|
2016-02-25 12:45:46 +00:00
|
|
|
instance.find_elements(css: '.modal button.js-submit')[0].click
|
2015-05-07 09:49:46 +00:00
|
|
|
(1..12).each {
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: 'body')[0]
|
2015-03-01 23:16:36 +00:00
|
|
|
text = element.text
|
|
|
|
if text =~ /#{Regexp.quote(data[:name])}/
|
2015-11-30 12:13:27 +00:00
|
|
|
assert(true, 'signature created')
|
2016-03-03 14:13:06 +00:00
|
|
|
sleep 1
|
2015-03-01 23:16:36 +00:00
|
|
|
return true
|
2012-12-14 10:14:48 +00:00
|
|
|
end
|
2015-03-01 23:16:36 +00:00
|
|
|
sleep 1
|
2012-12-14 10:14:48 +00:00
|
|
|
}
|
2015-11-30 12:13:27 +00:00
|
|
|
screenshot(browser: instance, comment: 'signature_create_failed')
|
2016-03-01 14:26:46 +00:00
|
|
|
raise 'signature creation failed'
|
2012-12-14 10:14:48 +00:00
|
|
|
end
|
2013-06-08 22:35:18 +00:00
|
|
|
|
2015-03-01 23:16:36 +00:00
|
|
|
=begin
|
2013-08-27 21:05:33 +00:00
|
|
|
|
2015-03-01 23:16:36 +00:00
|
|
|
group_create(
|
2015-11-29 15:39:56 +00:00
|
|
|
browser: browser2,
|
|
|
|
data: {
|
|
|
|
name: 'some sla' + random,
|
|
|
|
signature: 'some signature bame',
|
|
|
|
member: [
|
2015-03-01 23:16:36 +00:00
|
|
|
'some_user_login',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
)
|
2015-02-20 23:17:49 +00:00
|
|
|
|
2015-03-01 23:16:36 +00:00
|
|
|
=end
|
2014-10-11 23:35:53 +00:00
|
|
|
|
2015-03-01 23:16:36 +00:00
|
|
|
def group_create(params = {})
|
2015-11-29 15:39:56 +00:00
|
|
|
switch_window_focus(params)
|
2015-03-08 01:06:57 +00:00
|
|
|
log('group_create', params)
|
|
|
|
|
2015-03-01 23:16:36 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
data = params[:data]
|
2015-01-23 22:24:03 +00:00
|
|
|
|
2016-03-21 19:10:01 +00:00
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: 'a[href="#manage"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
click(
|
|
|
|
browser: instance,
|
2016-03-21 20:51:05 +00:00
|
|
|
css: 'a[href="#manage/groups"]',
|
2016-03-21 19:10:01 +00:00
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: 'a[data-type="new"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
|
2015-03-01 23:16:36 +00:00
|
|
|
sleep 2
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: '.modal input[name=name]')[0]
|
2015-03-01 23:16:36 +00:00
|
|
|
element.clear
|
2015-11-30 12:13:27 +00:00
|
|
|
element.send_keys(data[:name])
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: '.modal select[name="email_address_id"]')[0]
|
2015-03-01 23:16:36 +00:00
|
|
|
dropdown = Selenium::WebDriver::Support::Select.new(element)
|
2015-11-30 12:13:27 +00:00
|
|
|
dropdown.select_by(:index, 1)
|
|
|
|
#dropdown.select_by(:text, action[:group])
|
2015-03-01 23:16:36 +00:00
|
|
|
if data[:signature]
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: '.modal select[name="signature_id"]')[0]
|
2015-01-23 22:24:03 +00:00
|
|
|
dropdown = Selenium::WebDriver::Support::Select.new(element)
|
2015-11-30 12:13:27 +00:00
|
|
|
dropdown.select_by(:text, data[:signature])
|
2012-12-14 12:16:04 +00:00
|
|
|
end
|
2016-02-25 12:45:46 +00:00
|
|
|
instance.find_elements(css: '.modal button.js-submit')[0].click
|
2015-05-07 09:49:46 +00:00
|
|
|
(1..12).each {
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: 'body')[0]
|
2015-03-01 23:16:36 +00:00
|
|
|
text = element.text
|
|
|
|
if text =~ /#{Regexp.quote(data[:name])}/
|
2015-11-30 12:13:27 +00:00
|
|
|
assert(true, 'group created')
|
2016-05-06 08:19:24 +00:00
|
|
|
sleep 1 # wait until modal has gone
|
2015-03-01 23:16:36 +00:00
|
|
|
|
|
|
|
# add member
|
|
|
|
if data[:member]
|
|
|
|
data[:member].each {|login|
|
2016-02-25 12:45:46 +00:00
|
|
|
instance.find_elements(css: 'a[href="#manage"]')[0].click
|
2015-11-30 12:13:27 +00:00
|
|
|
sleep 0.5
|
2016-02-25 12:45:46 +00:00
|
|
|
instance.find_elements(css: 'a[href="#manage/users"]')[0].click
|
2015-11-30 12:13:27 +00:00
|
|
|
sleep 3
|
2016-02-25 12:45:46 +00:00
|
|
|
element = instance.find_elements(css: '#content [name="search"]')[0]
|
2015-03-01 23:16:36 +00:00
|
|
|
element.clear
|
2015-11-30 12:13:27 +00:00
|
|
|
element.send_keys(login)
|
|
|
|
sleep 3
|
2016-02-25 12:45:46 +00:00
|
|
|
#instance.find_elements(:css => '#content table [data-id]')[0].click
|
2015-11-30 12:13:27 +00:00
|
|
|
instance.execute_script('$("#content table [data-id] td").first().click()')
|
|
|
|
sleep 3
|
2016-02-25 12:45:46 +00:00
|
|
|
#instance.find_elements(:css => 'label:contains(" ' + action[:name] + '")')[0].click
|
2015-11-30 12:13:27 +00:00
|
|
|
instance.execute_script('$(\'label:contains(" ' + data[:name] + '")\').first().click()')
|
2016-02-25 12:45:46 +00:00
|
|
|
instance.find_elements(css: '.modal button.js-submit')[0].click
|
2016-03-07 03:24:08 +00:00
|
|
|
sleep 3
|
2013-02-23 22:54:48 +00:00
|
|
|
}
|
|
|
|
end
|
2012-12-14 12:16:04 +00:00
|
|
|
end
|
2015-03-01 23:16:36 +00:00
|
|
|
sleep 1
|
|
|
|
return true
|
|
|
|
}
|
2015-11-30 12:13:27 +00:00
|
|
|
screenshot(browser: instance, comment: 'group_create_failed')
|
2016-03-01 14:26:46 +00:00
|
|
|
raise 'group creation failed'
|
2012-12-14 12:16:04 +00:00
|
|
|
end
|
2015-03-01 23:16:36 +00:00
|
|
|
|
2016-05-25 07:19:45 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
object_manager_attribute_create(
|
|
|
|
browser: browser2,
|
|
|
|
data: {
|
|
|
|
name: 'field_name' + random,
|
|
|
|
display: 'Display Name of Field',
|
2016-05-26 08:14:51 +00:00
|
|
|
data_type: 'Text', # Text|Select|...
|
|
|
|
data_option: {
|
|
|
|
options: {
|
|
|
|
'aa' => 'AA',
|
|
|
|
'bb' => 'BB',
|
|
|
|
},
|
|
|
|
},
|
2016-05-25 07:19:45 +00:00
|
|
|
},
|
|
|
|
error: 'already exists'
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def object_manager_attribute_create(params = {})
|
|
|
|
switch_window_focus(params)
|
|
|
|
log('object_manager_attribute_create', params)
|
|
|
|
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
data = params[:data]
|
|
|
|
|
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: 'a[href="#manage"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: 'a[href="#system/object_manager"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
sleep 4
|
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: '#content .js-new',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
modal_ready
|
|
|
|
element = instance.find_elements(css: '.modal input[name=name]')[0]
|
|
|
|
element.clear
|
|
|
|
element.send_keys(data[:name])
|
|
|
|
element = instance.find_elements(css: '.modal input[name=display]')[0]
|
|
|
|
element.clear
|
|
|
|
element.send_keys(data[:display])
|
2016-05-26 08:14:51 +00:00
|
|
|
select(
|
|
|
|
browser: instance,
|
|
|
|
css: '.modal select[name="data_type"]',
|
|
|
|
value: data[:data_type],
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
if data[:data_option]
|
|
|
|
if data[:data_option][:options]
|
|
|
|
data[:data_option][:options].each {|key, value|
|
|
|
|
element = instance.find_elements(css: '.modal .js-Table .js-key').last
|
|
|
|
element.clear
|
|
|
|
element.send_keys(key)
|
|
|
|
element = instance.find_elements(css: '.modal .js-Table .js-value').last
|
|
|
|
element.clear
|
|
|
|
element.send_keys(value)
|
|
|
|
element = instance.find_elements(css: '.modal .js-Table .js-add')[0]
|
|
|
|
element.click
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
2016-05-25 07:19:45 +00:00
|
|
|
instance.find_elements(css: '.modal button.js-submit')[0].click
|
|
|
|
if params[:error]
|
|
|
|
sleep 4
|
|
|
|
watch_for(
|
|
|
|
css: '.modal',
|
|
|
|
value: params[:error],
|
|
|
|
)
|
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: '.modal .js-close',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
(1..12).each {
|
|
|
|
element = instance.find_elements(css: 'body')[0]
|
|
|
|
text = element.text
|
|
|
|
if text =~ /#{Regexp.quote(data[:name])}/
|
|
|
|
assert(true, 'object manager attribute created')
|
|
|
|
sleep 1
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
sleep 1
|
|
|
|
}
|
|
|
|
screenshot(browser: instance, comment: 'object_manager_attribute_create_failed')
|
|
|
|
raise 'object manager attribute creation failed'
|
|
|
|
end
|
|
|
|
|
2016-05-26 08:14:51 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
object_manager_attribute_delete(
|
|
|
|
browser: browser2,
|
|
|
|
data: {
|
|
|
|
name: 'field_name' + random,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def object_manager_attribute_delete(params = {})
|
|
|
|
switch_window_focus(params)
|
|
|
|
log('object_manager_attribute_delete', params)
|
|
|
|
|
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: 'a[href="#manage"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: 'a[href="#system/object_manager"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
sleep 4
|
|
|
|
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
data = params[:data]
|
|
|
|
r = instance.execute_script("$(\"#content td:contains('#{data[:name]}')\").first().closest('tr').find('.js-delete').click()")
|
|
|
|
p "rrr #{r.inspect}"
|
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
object_manager_attribute_discard_changes(
|
|
|
|
browser: browser2,
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def object_manager_attribute_discard_changes(params = {})
|
|
|
|
switch_window_focus(params)
|
|
|
|
log('object_manager_attribute_discard_changes', params)
|
|
|
|
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: 'a[href="#manage"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
click(
|
|
|
|
browser: instance,
|
|
|
|
css: 'a[href="#system/object_manager"]',
|
|
|
|
mute_log: true,
|
|
|
|
)
|
|
|
|
sleep 4
|
|
|
|
|
|
|
|
element = instance.find_elements(css: '#content .js-discard').first
|
|
|
|
element.click
|
|
|
|
|
|
|
|
watch_for_disappear(
|
|
|
|
browser: instance,
|
|
|
|
css: '#content .js-discard',
|
|
|
|
)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2015-03-01 23:16:36 +00:00
|
|
|
def quote(string)
|
|
|
|
string_quoted = string
|
|
|
|
string_quoted.gsub!(/&/, '&')
|
|
|
|
string_quoted.gsub!(/</, '<')
|
|
|
|
string_quoted.gsub!(/>/, '>')
|
|
|
|
string_quoted
|
|
|
|
end
|
|
|
|
|
2015-11-29 15:39:56 +00:00
|
|
|
def switch_window_focus(params)
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
if instance != @last_used_browser
|
|
|
|
log('switch browser window focus', {})
|
|
|
|
instance.switch_to.window(instance.window_handles.first)
|
|
|
|
end
|
|
|
|
@last_used_browser = instance
|
|
|
|
end
|
|
|
|
|
2016-03-15 11:47:26 +00:00
|
|
|
def log(method, params = {})
|
2015-03-08 01:06:57 +00:00
|
|
|
return if !@@debug
|
2015-11-17 09:03:51 +00:00
|
|
|
return if params[:mute_log]
|
2015-04-27 19:56:07 +00:00
|
|
|
puts "#{Time.zone.now}/#{method}: #{params.inspect}"
|
2015-03-08 01:06:57 +00:00
|
|
|
end
|
2015-04-27 14:15:29 +00:00
|
|
|
end
|