2012-12-14 10:14:48 +00:00
|
|
|
ENV["RAILS_ENV"] = "test"
|
|
|
|
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
|
2013-06-25 14:00:28 +00:00
|
|
|
def browser
|
|
|
|
ENV['BROWSER'] || 'firefox'
|
|
|
|
end
|
|
|
|
|
|
|
|
def browser_support_cookies
|
|
|
|
if browser =~ /(internet_explorer|ie)/i
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
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?
|
2013-06-25 14:00:28 +00:00
|
|
|
local_browser = Selenium::WebDriver.for( browser.to_sym )
|
2013-07-24 18:09:20 +00:00
|
|
|
browser_instance_preferences(local_browser)
|
2014-12-14 13:13:46 +00:00
|
|
|
@browsers[local_browser.hash] = local_browser
|
2013-06-25 14:00:28 +00:00
|
|
|
return local_browser
|
2013-02-23 22:54:48 +00:00
|
|
|
end
|
|
|
|
|
2013-08-11 07:56:58 +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,
|
|
|
|
:url => ENV['REMOTE_URL'],
|
|
|
|
:desired_capabilities => caps,
|
|
|
|
)
|
2013-07-24 18:09:20 +00:00
|
|
|
browser_instance_preferences(local_browser)
|
2014-12-14 13:13:46 +00:00
|
|
|
@browsers[local_browser.hash] = local_browser
|
2013-06-25 14:00:28 +00:00
|
|
|
return 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]
|
|
|
|
@browsers.delete( local_browser.hash )
|
|
|
|
local_browser.quit
|
|
|
|
end
|
|
|
|
|
2013-07-24 18:09:20 +00:00
|
|
|
def browser_instance_preferences(local_browser)
|
2013-11-14 21:30:44 +00:00
|
|
|
#local_browser.manage.window.resize_to(1024, 1024)
|
2013-07-24 18:09:20 +00:00
|
|
|
if ENV['REMOTE_URL'] !~ /saucelabs/i
|
|
|
|
if @browsers.size < 1
|
|
|
|
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
|
2014-12-14 13:13:46 +00:00
|
|
|
@browsers.each { |hash, local_browser|
|
|
|
|
browser_instance_close(local_browser)
|
|
|
|
}
|
2013-02-23 22:54:48 +00:00
|
|
|
end
|
2012-12-14 10:14:48 +00:00
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
username = login(
|
|
|
|
:browser => browser1,
|
|
|
|
:username => 'someuser',
|
|
|
|
:password => 'somepassword',
|
|
|
|
:url => 'some url', # optional
|
|
|
|
:remember_me => true, # optional
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def login(params)
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
|
|
|
if params[:url]
|
|
|
|
instance.get( params[:url] )
|
|
|
|
end
|
|
|
|
|
|
|
|
element = instance.find_elements( { :css => '#login input[name="username"]' } )[0]
|
|
|
|
if !element
|
|
|
|
raise "No login box found"
|
|
|
|
end
|
|
|
|
element.clear
|
|
|
|
element.send_keys( params[:username] )
|
|
|
|
|
|
|
|
element = instance.find_elements( { :css => '#login input[name="password"]' } )[0]
|
|
|
|
element.clear
|
|
|
|
element.send_keys( params[:password] )
|
|
|
|
|
|
|
|
if params[:remember_me]
|
|
|
|
instance.find_elements( { :css => '#login [name="remember_me"]' } )[0].click
|
|
|
|
end
|
|
|
|
instance.find_elements( { :css => '#login button' } )[0].click
|
|
|
|
|
|
|
|
sleep 4
|
|
|
|
login = instance.find_elements( { :css => '.user-menu .user a' } )[0].attribute('title')
|
|
|
|
if login != params[:username]
|
|
|
|
raise "login failed"
|
|
|
|
end
|
|
|
|
assert( true, "login ok" )
|
|
|
|
login
|
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
logout(
|
|
|
|
:browser => browser1
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def logout(params = {})
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
|
|
|
instance.find_elements( { :css => 'a[href="#current_user"]' } )[0].click
|
|
|
|
sleep 0.1
|
|
|
|
instance.find_elements( { :css => 'a[href="#logout"]' } )[0].click
|
|
|
|
(1..6).each {|loop|
|
|
|
|
login = instance.find_elements( { :css => '#login' } )[0]
|
|
|
|
if login
|
|
|
|
assert( true, "logout ok" )
|
|
|
|
return
|
|
|
|
end
|
|
|
|
}
|
|
|
|
raise "no login box found, seems logout was not successfully!"
|
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
location(
|
|
|
|
:browser => browser1,
|
|
|
|
:url => 'http://someurl',
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def location(params)
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
instance.get( params[:url] )
|
|
|
|
end
|
|
|
|
|
2015-02-22 22:20:05 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
location_check(
|
|
|
|
:browser => browser1,
|
|
|
|
:url => 'http://someurl',
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def location_check(params)
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
if instance.current_url !~ /#{Regexp.quote(params[:url])}/
|
|
|
|
raise "url #{instance.current_url} is not matching #{params[:url]}"
|
|
|
|
end
|
|
|
|
assert( true, "url #{instance.current_url} is matching #{params[:url]}" )
|
|
|
|
end
|
2015-02-22 12:28:34 +00:00
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
reload(
|
|
|
|
:browser => browser1,
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def reload(params = {})
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
instance.navigate.refresh
|
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
click(
|
|
|
|
:browser => browser1,
|
|
|
|
:css => '.some_class',
|
2015-02-28 10:40:23 +00:00
|
|
|
:fast => false, # do not wait
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def click(params)
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
instance.find_elements( { :css => params[:css] } )[0].click
|
2015-02-28 10:40:23 +00:00
|
|
|
if !params[:fast]
|
|
|
|
sleep 0.4
|
|
|
|
end
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
exists(
|
|
|
|
:browser => browser1,
|
|
|
|
:css => '.some_class',
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def exists(params)
|
2015-02-22 22:20:05 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
if !instance.find_elements( { :css => params[:css] } )[0]
|
|
|
|
raise "#{params[:css]} dosn't exist, but should"
|
|
|
|
end
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
exists_not(
|
|
|
|
:browser => browser1,
|
|
|
|
:css => '.some_class',
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def exists_not(params)
|
2015-02-22 12:28:34 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
if instance.find_elements( { :css => params[:css] } )[0]
|
2015-02-22 22:20:05 +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-02-26 12:41:09 +00:00
|
|
|
:browser => browser1,
|
|
|
|
:css => '.some_class',
|
|
|
|
:value => true,
|
|
|
|
:slow => false,
|
|
|
|
:blur => true,
|
|
|
|
:clear => true, # todo | default: true
|
|
|
|
:contenteditable => true
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def set(params)
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
|
|
|
element = instance.find_elements( { :css => params[:css] } )[0]
|
2015-02-26 12:41:09 +00:00
|
|
|
#element.click
|
2015-02-22 12:28:34 +00:00
|
|
|
element.clear
|
|
|
|
|
|
|
|
if !params[:slow]
|
|
|
|
element.send_keys( params[:value] )
|
|
|
|
else
|
|
|
|
element.send_keys( '' )
|
|
|
|
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]
|
|
|
|
instance.execute_script( "$('#{params[:css]}').blur()" )
|
|
|
|
end
|
2015-02-28 10:40:23 +00:00
|
|
|
|
|
|
|
# it's not working stable via selenium, use js
|
|
|
|
if params[:contenteditable]
|
|
|
|
value = instance.find_elements( { :css => params[:css] } )[0].text
|
|
|
|
if value != params[:value]
|
2015-03-01 09:11:13 +00:00
|
|
|
body_quoted = quote( params[:value] )
|
|
|
|
instance.execute_script( "$('#{params[:css]}').focus().html('#{body_quoted}').trigger('focusout')" )
|
2015-02-28 10:40:23 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-02-23 22:58:05 +00:00
|
|
|
sleep 0.5
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
|
2015-02-22 22:20:05 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
select(
|
|
|
|
:browser => browser1,
|
|
|
|
:css => '.some_class',
|
|
|
|
:value => 'Some Value',
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def select(params)
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
2015-02-24 01:31:17 +00:00
|
|
|
begin
|
|
|
|
element = instance.find_elements( { :css => params[:css] } )[0]
|
|
|
|
dropdown = Selenium::WebDriver::Support::Select.new(element)
|
|
|
|
dropdown.select_by(:text, params[:value])
|
|
|
|
rescue
|
|
|
|
# just try again
|
|
|
|
element = instance.find_elements( { :css => params[:css] } )[0]
|
|
|
|
dropdown = Selenium::WebDriver::Support::Select.new(element)
|
|
|
|
dropdown.select_by(:text, params[:value])
|
|
|
|
end
|
2015-02-22 22:20:05 +00:00
|
|
|
end
|
|
|
|
|
2015-02-23 06:56:45 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
check(
|
|
|
|
:browser => browser1,
|
|
|
|
:css => '.some_class',
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def check(params)
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
|
|
|
element = instance.find_elements( { :css => params[:css] } )[0]
|
|
|
|
checked = element.attribute('checked')
|
|
|
|
if !checked
|
|
|
|
element.click
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
uncheck(
|
|
|
|
:browser => browser1,
|
|
|
|
:css => '.some_class',
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def uncheck(params)
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
|
|
|
element = instance.find_elements( { :css => params[:css] } )[0]
|
|
|
|
checked = element.attribute('checked')
|
|
|
|
if checked
|
|
|
|
element.click
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
sendkey(
|
|
|
|
:browser => browser1,
|
|
|
|
:value => :enter,
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def sendkey(params)
|
|
|
|
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-02-23 22:58:05 +00:00
|
|
|
sleep 0.5
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
match(
|
|
|
|
: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
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
2015-03-01 23:16:36 +00:00
|
|
|
def match(params, fallback = false)
|
2015-02-22 12:28:34 +00:00
|
|
|
instance = params[:browser] || @browser
|
2015-02-28 10:40:23 +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
|
|
|
|
raise "should not match '#{params[:value]}' in select list, but is matching"
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
if !success
|
|
|
|
raise "not matching '#{params[:value]}' in select list"
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-02-24 01:31:17 +00:00
|
|
|
# match on attribute
|
2015-02-28 10:40:23 +00:00
|
|
|
begin
|
|
|
|
if params[:attribute]
|
|
|
|
text = element.attribute( params[:attribute] )
|
|
|
|
elsif params[:css] =~ /(input|textarea)/i
|
|
|
|
text = element.attribute('value')
|
|
|
|
else
|
|
|
|
text = element.text
|
|
|
|
end
|
|
|
|
rescue
|
|
|
|
|
|
|
|
# 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
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
match = false
|
|
|
|
if params[:no_quote]
|
|
|
|
#puts "aaaa #{text}/#{params[:value]}"
|
|
|
|
if text =~ /#{params[:value]}/i
|
|
|
|
match = $1 || true
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if text =~ /#{Regexp.quote(params[:value])}/i
|
|
|
|
match = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if match
|
|
|
|
if params[:should_not_match]
|
|
|
|
raise "matching '#{params[:value]}' in content '#{text}' but should not!"
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if !params[:should_not_match]
|
|
|
|
raise "not matching '#{params[:value]}' in content '#{text}' but should!"
|
|
|
|
end
|
|
|
|
end
|
2015-02-23 22:58:05 +00:00
|
|
|
sleep 0.8
|
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(
|
|
|
|
: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
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def match_not(params)
|
|
|
|
params[:should_not_match] = true
|
|
|
|
match(params)
|
|
|
|
end
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
cookie(
|
|
|
|
:browser => browser1,
|
|
|
|
:name => '^_zammad.+?',
|
|
|
|
:value => '.+?',
|
|
|
|
:expires => nil,
|
|
|
|
)
|
|
|
|
|
|
|
|
cookie(
|
|
|
|
:browser => browser1,
|
|
|
|
:name => '^_zammad.+?',
|
|
|
|
:should_not_exist => true,
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def cookie(params)
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
|
|
|
if !browser_support_cookies
|
|
|
|
assert( true, "'#{params[:value]}' ups browser is not supporting reading cookies, go ahead")
|
|
|
|
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}
|
|
|
|
if cookie[:name] =~ /#{params[:name]}/i
|
|
|
|
if params.has_key?( :value ) && cookie[:value].to_s =~ /#{params[:value]}/i
|
|
|
|
assert( true, "matching value '#{params[:value]}' in cookie '#{cookie.to_s}'" )
|
|
|
|
else
|
|
|
|
raise "not matching value '#{params[:value]}' in cookie '#{cookie.to_s}'"
|
|
|
|
end
|
|
|
|
if params.has_key?( :expires ) && cookie[:expires].to_s =~ /#{params[:expires]}/i
|
|
|
|
assert( true, "matching expires '#{params[:expires].inspect}' in cookie '#{cookie.to_s}'" )
|
|
|
|
else
|
|
|
|
raise "not matching expires '#{params[:expires]}' in cookie '#{cookie.to_s}'"
|
|
|
|
end
|
|
|
|
|
|
|
|
if params[:should_not_exist]
|
|
|
|
raise "cookie with name '#{params[:name]}' should not exist, but exists '#{cookies.to_s}'"
|
|
|
|
end
|
|
|
|
return
|
|
|
|
end
|
|
|
|
}
|
|
|
|
if params[:should_not_exist]
|
|
|
|
assert( true, "cookie with name '#{params[:name]}' is not existing" )
|
|
|
|
return
|
|
|
|
end
|
|
|
|
raise "not matching name '#{params[:name]}' in cookie '#{cookies.to_s}'"
|
|
|
|
end
|
|
|
|
|
2015-02-28 18:51:40 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
verify_title(
|
|
|
|
:browser => browser1,
|
|
|
|
:value => 'some title',
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def verify_title(params = {})
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
|
|
|
title = instance.title
|
|
|
|
if title =~ /#{params[:value]}/i
|
|
|
|
assert( true, "matching '#{params[:value]}' in title '#{title}'" )
|
|
|
|
else
|
|
|
|
raise "not matching '#{params[:value]}' in title '#{title}'"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
verify_task(
|
|
|
|
:browser => browser1,
|
|
|
|
:data => {
|
|
|
|
:title => 'some title',
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
2015-03-01 23:16:36 +00:00
|
|
|
def verify_task(params = {}, fallback = false)
|
2015-02-28 18:51:40 +00:00
|
|
|
instance = params[:browser] || @browser
|
|
|
|
data = params[:data]
|
|
|
|
|
2015-03-01 23:16:36 +00:00
|
|
|
begin
|
|
|
|
if data[:title]
|
|
|
|
title = instance.find_elements( { :css => '.tasks .active' } )[0].text.strip
|
|
|
|
if title =~ /#{data[:title]}/i
|
|
|
|
assert( true, "matching '#{data[:title]}' in title '#{title}'" )
|
|
|
|
else
|
|
|
|
raise "not matching '#{data[:title]}' in title '#{title}'"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
rescue
|
|
|
|
# just try again
|
|
|
|
if !fallback
|
|
|
|
verify_task(params, true)
|
2015-02-28 18:51:40 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2015-03-02 13:39:27 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
open_task(
|
|
|
|
:browser => browser1,
|
|
|
|
:data => {
|
|
|
|
:title => 'some title',
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def open_task(params = {}, fallback = false)
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
data = params[:data]
|
|
|
|
|
|
|
|
element = instance.find_elements( { :partial_link_text => data[:title] } )[0]
|
|
|
|
if !element
|
|
|
|
raise "no task with title '#{data[:title]}' found"
|
|
|
|
end
|
|
|
|
element.click
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2015-02-28 10:40:23 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
file_upload(
|
|
|
|
:browser => browser1,
|
|
|
|
:css => '#content .text-1',
|
|
|
|
:value => 'some text',
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def file_upload(params = {})
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
|
|
|
filename = 'some-file.txt'
|
|
|
|
file = File.join(Dir.pwd, filename)
|
|
|
|
#file = 'some test lalal'
|
|
|
|
|
|
|
|
element = instance.find_elements( { :css => params[:css] } )[0].send_keys file
|
|
|
|
#instance.find_elements( { :css => params[:css] } )[0]
|
|
|
|
#element
|
|
|
|
#@driver.find_element(id: 'file-submit').click
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
watch_for(
|
2015-02-24 01:31:17 +00:00
|
|
|
:browser => browser1,
|
2015-02-28 10:40:23 +00:00
|
|
|
:css => '#content .text-1',
|
2015-02-24 01:31:17 +00:00
|
|
|
:value => 'some text',
|
|
|
|
:attribute => 'some_attribute' # optional
|
|
|
|
:timeout => '16', # in sec, default 16
|
2015-02-22 12:28:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def watch_for(params = {})
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
|
|
|
timeout = 16
|
|
|
|
if params[:timeout]
|
|
|
|
timeout = params[:timeout]
|
|
|
|
end
|
2015-03-02 13:39:27 +00:00
|
|
|
loops = (timeout).to_i * 2
|
2015-02-22 12:28:34 +00:00
|
|
|
text = ''
|
|
|
|
(1..loops).each { |loop|
|
|
|
|
element = instance.find_elements( { :css => params[:css] } )[0]
|
|
|
|
if element #&& element.displayed?
|
|
|
|
begin
|
2015-02-24 01:31:17 +00:00
|
|
|
|
|
|
|
# match pn attribute
|
|
|
|
if params[:attribute]
|
|
|
|
text = element.attribute( params[:attribute] )
|
|
|
|
elsif params[:css] =~ /(input|textarea)/i
|
|
|
|
text = element.attribute('value')
|
|
|
|
else
|
|
|
|
text = element.text
|
|
|
|
end
|
2015-02-22 12:28:34 +00:00
|
|
|
if text =~ /#{params[:value]}/i
|
|
|
|
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
|
|
|
|
rescue
|
|
|
|
# just try again
|
|
|
|
end
|
|
|
|
end
|
2015-03-02 13:39:27 +00:00
|
|
|
sleep 0.5
|
2015-02-22 12:28:34 +00:00
|
|
|
}
|
|
|
|
raise "'#{params[:value]}' found in '#{text}'"
|
|
|
|
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(
|
|
|
|
:browser => browser1,
|
2015-02-28 10:40:23 +00:00
|
|
|
:css => '#content .text-1',
|
2015-02-23 22:37:00 +00:00
|
|
|
:timeout => '16', # in sec, default 16
|
|
|
|
)
|
|
|
|
|
2015-02-28 18:51:40 +00:00
|
|
|
wait untill text in selector disabppears
|
|
|
|
|
|
|
|
watch_for_disappear(
|
|
|
|
:browser => browser1,
|
|
|
|
:css => '#content .text-1',
|
|
|
|
:value => 'some value as regexp',
|
|
|
|
:timeout => '16', # in sec, default 16
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2015-02-23 22:37:00 +00:00
|
|
|
=end
|
|
|
|
|
|
|
|
def watch_for_disappear(params = {})
|
|
|
|
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
|
|
|
|
loops = (timeout).to_i
|
2015-02-28 10:40:23 +00:00
|
|
|
text = ''
|
2015-02-23 22:37:00 +00:00
|
|
|
(1..loops).each { |loop|
|
|
|
|
element = instance.find_elements( { :css => params[:css] } )[0]
|
|
|
|
if !element #|| element.displayed?
|
|
|
|
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
|
|
|
|
text = instance.find_elements( { :css => params[:css] } )[0].text
|
|
|
|
if text !~ /#{params[:value]}/i
|
|
|
|
assert( true, "not matching '#{params[:value]}' in text '#{text}'" )
|
|
|
|
sleep 1
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
rescue
|
|
|
|
# just try again
|
|
|
|
end
|
|
|
|
end
|
2015-02-23 22:37:00 +00:00
|
|
|
sleep 1
|
|
|
|
}
|
2015-02-24 00:11:10 +00:00
|
|
|
raise "#{params[:css]}) still exsists"
|
2015-02-23 22:37:00 +00:00
|
|
|
end
|
2015-02-22 12:28:34 +00:00
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
tasks_close_all(
|
|
|
|
:browser => browser1,
|
|
|
|
:discard_changes => true,
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def tasks_close_all(params = {})
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
|
|
|
for i in 1..100
|
|
|
|
sleep 1
|
2015-02-22 22:51:44 +00:00
|
|
|
begin
|
|
|
|
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] )
|
|
|
|
sleep 0.2
|
|
|
|
|
|
|
|
click_element = instance.find_elements( { :css => '.navigation .tasks .task:first-child .js-close' } )[0]
|
|
|
|
if click_element
|
|
|
|
sleep 0.1
|
|
|
|
click_element.click
|
|
|
|
|
|
|
|
# accept task close warning
|
|
|
|
if params[:discard_changes]
|
|
|
|
sleep 1
|
|
|
|
instance.find_elements( { :css => '.modal button.js-submit' } )[0].click
|
|
|
|
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-02-22 22:51:44 +00:00
|
|
|
rescue
|
|
|
|
# just try again
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
end
|
2015-02-23 22:58:05 +00:00
|
|
|
sleep 1
|
2015-02-22 12:28:34 +00:00
|
|
|
assert( true, "all tasks closed" )
|
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
username = overview_create(
|
|
|
|
:browser => browser1,
|
|
|
|
:data => {
|
|
|
|
:name => name,
|
|
|
|
:link => name,
|
|
|
|
:role => 'Agent',
|
|
|
|
:prio => 1000,
|
|
|
|
'order::direction' => 'down',
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def overview_create(params)
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
data = params[:data]
|
|
|
|
|
|
|
|
instance.find_elements( { :css => 'a[href="#manage"]' } )[0].click
|
|
|
|
instance.find_elements( { :css => 'a[href="#manage/overviews"]' } )[0].click
|
2015-02-28 10:40:23 +00:00
|
|
|
sleep 0.2
|
2015-02-22 12:28:34 +00:00
|
|
|
instance.find_elements( { :css => '#content a[data-type="new"]' } )[0].click
|
|
|
|
sleep 2
|
|
|
|
|
|
|
|
if data[:name]
|
|
|
|
element = instance.find_elements( { :css => '.modal input[name=name]' } )[0]
|
|
|
|
element.clear
|
|
|
|
element.send_keys( data[:name] )
|
|
|
|
end
|
|
|
|
if data[:link]
|
|
|
|
element = instance.find_elements( { :css => '.modal input[name=link]' } )[0]
|
|
|
|
element.clear
|
|
|
|
element.send_keys( data[:link] )
|
|
|
|
end
|
|
|
|
if data[:role]
|
|
|
|
element = instance.find_elements( { :css => '.modal select[name="role_id"]' } )[0]
|
|
|
|
dropdown = Selenium::WebDriver::Support::Select.new(element)
|
|
|
|
dropdown.select_by( :text, data[:role])
|
|
|
|
end
|
|
|
|
if data[:prio]
|
|
|
|
element = instance.find_elements( { :css => '.modal input[name=prio]' } )[0]
|
|
|
|
element.clear
|
|
|
|
element.send_keys( data[:prio] )
|
|
|
|
end
|
|
|
|
if data['order::direction']
|
|
|
|
element = instance.find_elements( { :css => '.modal select[name="order::direction"]' } )[0]
|
|
|
|
dropdown = Selenium::WebDriver::Support::Select.new(element)
|
|
|
|
dropdown.select_by( :text, data['order::direction'])
|
|
|
|
end
|
|
|
|
|
|
|
|
instance.find_elements( { :css => '.modal button.js-submit' } )[0].click
|
|
|
|
(1..12).each {|loop|
|
|
|
|
element = instance.find_elements( { :css => 'body' } )[0]
|
|
|
|
text = element.text
|
|
|
|
if text =~ /#{Regexp.quote(data[:name])}/
|
|
|
|
assert( true, "overview created" )
|
|
|
|
overview = {
|
|
|
|
:name => name,
|
|
|
|
}
|
|
|
|
return overview
|
|
|
|
end
|
|
|
|
sleep 1
|
|
|
|
}
|
|
|
|
raise "overview creation failed"
|
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
ticket = ticket_create(
|
|
|
|
:browser => browser1,
|
|
|
|
:data => {
|
|
|
|
:customer => 'nico',
|
|
|
|
:group => 'Users',
|
2015-02-23 13:02:46 +00:00
|
|
|
:title => 'overview #1',
|
2015-02-22 12:28:34 +00:00
|
|
|
:body => 'overview #1',
|
|
|
|
},
|
|
|
|
:do_not_submit => true,
|
|
|
|
)
|
|
|
|
|
|
|
|
returns (in case of submitted)
|
|
|
|
{
|
|
|
|
:id => 123,
|
|
|
|
:number => '100001',
|
|
|
|
}
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def ticket_create(params)
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
data = params[:data]
|
|
|
|
|
|
|
|
instance.find_elements( { :css => 'a[href="#new"]' } )[0].click
|
|
|
|
instance.find_elements( { :css => 'a[href="#ticket/create"]' } )[0].click
|
|
|
|
element = instance.find_elements( { :css => '.active .newTicket' } )[0]
|
|
|
|
if !element
|
|
|
|
raise "no ticket create screen found!"
|
|
|
|
end
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
# check count of agents, should be only 1 / - selection on init screen
|
|
|
|
count = instance.find_elements( { :css => '.active .newTicket select[name="owner_id"] option' } ).count
|
|
|
|
assert_equal( 1, count, 'check if owner selection is empty per default' )
|
|
|
|
|
|
|
|
if data[:group]
|
|
|
|
element = instance.find_elements( { :css => '.active .newTicket select[name="group_id"]' } )[0]
|
|
|
|
dropdown = Selenium::WebDriver::Support::Select.new(element)
|
|
|
|
dropdown.select_by( :text, data[:group])
|
|
|
|
sleep 0.2
|
|
|
|
end
|
|
|
|
if data[:title]
|
|
|
|
element = instance.find_elements( { :css => '.active .newTicket input[name="title"]' } )[0]
|
|
|
|
element.clear
|
|
|
|
element.send_keys( data[:title] )
|
|
|
|
sleep 0.2
|
|
|
|
end
|
|
|
|
if data[:body]
|
|
|
|
#instance.execute_script( '$(".active .newTicket div[data-name=body]").focus()' )
|
|
|
|
sleep 0.5
|
|
|
|
element = instance.find_elements( { :css => '.active .newTicket div[data-name=body]' } )[0]
|
|
|
|
element.clear
|
|
|
|
element.send_keys( data[:body] )
|
2015-02-28 10:40:23 +00:00
|
|
|
|
|
|
|
# it's not working stable via selenium, use js
|
|
|
|
value = instance.find_elements( { :css => '.content .newTicket div[data-name=body]' } )[0].text
|
|
|
|
puts "V #{value.inspect}"
|
|
|
|
if value != data[:body]
|
2015-03-01 09:11:13 +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]
|
|
|
|
element = instance.find_elements( { :css => '.active .newTicket input[name="customer_id_completion"]' } )[0]
|
|
|
|
element.click
|
|
|
|
element.clear
|
2015-02-28 10:40:23 +00:00
|
|
|
|
|
|
|
# workaround, sometimes focus is not triggered
|
2015-02-22 12:28:34 +00:00
|
|
|
element.send_keys( data[:customer] )
|
|
|
|
sleep 4
|
2015-02-28 10:40:23 +00:00
|
|
|
|
|
|
|
# check if pulldown is open, it's not working stable via selenium
|
|
|
|
res = instance.execute_script( "$('.active .newTicket .js-recipientDropdown').hasClass('open')" )
|
|
|
|
puts "res #{res.inspect}"
|
|
|
|
if !res
|
|
|
|
puts "IS NOT OPEN!, open it"
|
|
|
|
instance.execute_script( "$('.active .newTicket .js-recipientDropdown').addClass('open')" )
|
|
|
|
end
|
2015-02-22 12:28:34 +00:00
|
|
|
element.send_keys( :arrow_down )
|
2015-02-28 10:40:23 +00:00
|
|
|
sleep 0.3
|
2015-02-22 12:28:34 +00:00
|
|
|
instance.find_elements( { :css => '.active .newTicket .recipientList-entry.js-user.is-active' } )[0].click
|
|
|
|
sleep 0.3
|
|
|
|
end
|
2015-02-28 10:40:23 +00:00
|
|
|
|
2015-02-28 18:51:40 +00:00
|
|
|
if data[:attachment]
|
|
|
|
file_upload(
|
|
|
|
:browser => instance,
|
|
|
|
:css => '#content .text-1',
|
|
|
|
:value => 'some text',
|
|
|
|
)
|
|
|
|
end
|
2015-02-28 10:40:23 +00:00
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
if params[:do_not_submit]
|
|
|
|
assert( true, "ticket created without submit" )
|
|
|
|
return
|
|
|
|
end
|
|
|
|
sleep 0.8
|
|
|
|
#instance.execute_script( '$(".content.active .newTicket form").submit();' )
|
|
|
|
instance.find_elements( { :css => '.active .newTicket button.submit' } )[0].click
|
|
|
|
sleep 1
|
2015-03-01 23:16:36 +00:00
|
|
|
(1..8).each {|loop|
|
2015-02-22 12:28:34 +00:00
|
|
|
if instance.current_url =~ /#{Regexp.quote('#ticket/zoom/')}/
|
|
|
|
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
|
|
|
|
id.gsub!(//, )
|
|
|
|
id.gsub!(/^.+?\/(\d+)$/, "\\1")
|
|
|
|
|
2015-03-01 23:16:36 +00:00
|
|
|
element = instance.find_elements( { :css => '.active .page-header .ticket-number' } )[0]
|
|
|
|
if element
|
|
|
|
number = element.text
|
|
|
|
ticket = {
|
|
|
|
:id => id,
|
|
|
|
:number => number,
|
|
|
|
}
|
|
|
|
sleep 1
|
|
|
|
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
|
|
|
}
|
|
|
|
raise "ticket creation failed, can't get zoom url"
|
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
ticket_update(
|
|
|
|
:browser => browser1,
|
|
|
|
:data => {
|
2015-02-23 15:35:48 +00:00
|
|
|
:title => '',
|
|
|
|
:body => 'some body',
|
2015-02-22 12:28:34 +00:00
|
|
|
:group => 'some group',
|
|
|
|
:state => 'closed',
|
|
|
|
},
|
|
|
|
:do_not_submit => true,
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def ticket_update(params)
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
data = params[:data]
|
|
|
|
|
2015-02-23 15:35:48 +00:00
|
|
|
|
|
|
|
if data[:title]
|
|
|
|
#element = instance.find_elements( { :css => '.content.active .page-header .ticket-title-update' } )[0]
|
|
|
|
#element.clear
|
|
|
|
#sleep 0.5
|
|
|
|
#element = instance.find_elements( { :css => '.content.active .page-header .ticket-title-update' } )[0]
|
|
|
|
#element.send_keys( data[:title] )
|
|
|
|
#sleep 0.5
|
|
|
|
#element.send_keys( :tab )
|
|
|
|
|
|
|
|
instance.execute_script( '$(".content.active .page-header .ticket-title-update").focus()' )
|
|
|
|
instance.execute_script( '$(".content.active .page-header .ticket-title-update").text("' + data[:title] + '")' )
|
|
|
|
instance.execute_script( '$(".content.active .page-header .ticket-title-update").blur()' )
|
|
|
|
instance.execute_script( '$(".content.active .page-header .ticket-title-update").trigger("blur")' )
|
|
|
|
# {
|
|
|
|
# :where => :instance2,
|
|
|
|
# :execute => 'sendkey',
|
|
|
|
# :css => '.content.active .page-header .ticket-title-update',
|
|
|
|
# :value => 'TTT',
|
|
|
|
# },
|
|
|
|
# {
|
|
|
|
# :where => :instance2,
|
|
|
|
# :execute => 'sendkey',
|
|
|
|
# :css => '.content.active .page-header .ticket-title-update',
|
|
|
|
# :value => :tab,
|
|
|
|
# },
|
|
|
|
end
|
|
|
|
if data[:body]
|
|
|
|
#instance.execute_script( '$(".content.active div[data-name=body]").focus()' )
|
|
|
|
sleep 0.5
|
|
|
|
element = instance.find_elements( { :css => '.content.active div[data-name=body]' } )[0]
|
|
|
|
element.clear
|
|
|
|
element.send_keys( data[:body] )
|
2015-02-28 10:40:23 +00:00
|
|
|
|
|
|
|
# it's not working stable via selenium, use js
|
|
|
|
value = instance.find_elements( { :css => '.content.active div[data-name=body]' } )[0].text
|
|
|
|
puts "V #{value.inspect}"
|
|
|
|
if value != data[:body]
|
2015-03-01 09:11:13 +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]
|
|
|
|
element = instance.find_elements( { :css => '.active .sidebar select[name="group_id"]' } )[0]
|
|
|
|
dropdown = Selenium::WebDriver::Support::Select.new(element)
|
|
|
|
dropdown.select_by( :text, data[:group])
|
|
|
|
sleep 0.2
|
|
|
|
end
|
|
|
|
|
|
|
|
if data[:state]
|
|
|
|
element = instance.find_elements( { :css => '.active .sidebar select[name="state_id"]' } )[0]
|
|
|
|
dropdown = Selenium::WebDriver::Support::Select.new(element)
|
|
|
|
dropdown.select_by( :text, data[:state])
|
|
|
|
sleep 0.2
|
|
|
|
end
|
|
|
|
|
|
|
|
found = nil
|
|
|
|
(1..5).each {|loop|
|
|
|
|
if !found
|
2015-02-22 22:51:44 +00:00
|
|
|
begin
|
|
|
|
text = instance.find_elements( { :css => '.content.active .js-reset' } )[0].text
|
|
|
|
if text =~ /(Discard your unsaved changes.|Verwerfen der)/
|
|
|
|
found = true
|
|
|
|
end
|
|
|
|
rescue
|
|
|
|
# just try again
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
sleep 1
|
|
|
|
end
|
|
|
|
}
|
|
|
|
if !found
|
|
|
|
raise "no discard message found"
|
|
|
|
end
|
|
|
|
|
|
|
|
if params[:do_not_submit]
|
2015-02-28 18:51:40 +00:00
|
|
|
assert( true, "ticket updated without submit" )
|
2015-02-22 12:28:34 +00:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
instance.find_elements( { :css => '.content.active button.js-submit' } )[0].click
|
|
|
|
|
|
|
|
(1..10).each {|loop|
|
2015-02-24 00:11:10 +00:00
|
|
|
begin
|
|
|
|
text = instance.find_elements( { :css => '.content.active .js-reset' } )[0].text
|
|
|
|
if !text || text.empty?
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
rescue
|
|
|
|
# just try again
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
sleep 1
|
|
|
|
}
|
|
|
|
raise "unable to update ticket"
|
|
|
|
end
|
|
|
|
|
2015-02-28 18:51:40 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
ticket_verify(
|
|
|
|
:browser => browser1,
|
|
|
|
:data => {
|
|
|
|
:title => 'some title',
|
|
|
|
:body => 'some body',
|
|
|
|
## :group => 'some group',
|
|
|
|
## :state => 'closed',
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def ticket_verify(params)
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
data = params[:data]
|
|
|
|
|
|
|
|
if data[:title]
|
|
|
|
title = instance.find_elements( { :css => '.content.active .page-header .ticket-title-update' } )[0].text.strip
|
|
|
|
if title =~ /#{data[:title]}/i
|
|
|
|
assert( true, "matching '#{data[:title]}' in title '#{title}'" )
|
|
|
|
else
|
|
|
|
raise "not matching '#{data[:title]}' in title '#{title}'"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if data[:body]
|
|
|
|
body = instance.find_elements( { :css => '.content.active [data-name="body"]' } )[0].text.strip
|
|
|
|
if body =~ /#{data[:body]}/i
|
|
|
|
assert( true, "matching '#{data[:body]}' in body '#{body}'" )
|
|
|
|
else
|
|
|
|
raise "not matching '#{data[:body]}' in body '#{body}'"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2015-02-22 12:28:34 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
ticket_open_by_overview(
|
|
|
|
:browser => browser2,
|
|
|
|
:number => ticket1[:number],
|
|
|
|
:link => '#ticket/view/' + name,
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def ticket_open_by_overview(params)
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
|
|
|
instance.find_elements( { :css => '#navigation li.overviews a' } )[0].click
|
|
|
|
sleep 1
|
|
|
|
instance.find_elements( { :css => ".content.active .sidebar a[href=\"#{params[:link]}\"]" } )[0].click
|
|
|
|
sleep 1
|
|
|
|
element = instance.find_elements( { :partial_link_text => params[:number] } )[0].click
|
|
|
|
sleep 1
|
|
|
|
number = instance.find_elements( { :css => '.active .page-header .ticket-number' } )[0].text
|
|
|
|
if number !~ /#{params[:number]}/
|
|
|
|
raise "unable to search/find ticket #{params[:number]}!"
|
|
|
|
end
|
2015-02-28 10:40:23 +00:00
|
|
|
sleep 1
|
2015-02-22 12:28:34 +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(
|
|
|
|
:browser => browser2,
|
|
|
|
:number => ticket1[:number],
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def ticket_open_by_search(params)
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
|
|
|
# search by number
|
|
|
|
element = instance.find_elements( { :css => '#global-search' } )[0]
|
|
|
|
element.click
|
|
|
|
element.clear
|
|
|
|
element.send_keys( params[:number] )
|
|
|
|
sleep 3
|
|
|
|
|
|
|
|
# empty search box by x
|
|
|
|
instance.find_elements( { :css => '.search .empty-search' } )[0].click
|
|
|
|
sleep 0.5
|
|
|
|
text = instance.find_elements( { :css => '#global-search' } )[0].attribute('value')
|
|
|
|
if !text
|
|
|
|
raise "#global-search is not empty!"
|
|
|
|
end
|
|
|
|
|
|
|
|
# search by number again
|
|
|
|
element = instance.find_elements( { :css => '#global-search' } )[0]
|
|
|
|
element.click
|
|
|
|
element.clear
|
|
|
|
element.send_keys( params[:number] )
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
# open ticket
|
|
|
|
element = instance.find_element( { :partial_link_text => params[:number] } ).click
|
|
|
|
number = instance.find_elements( { :css => '.active .page-header .ticket-number' } )[0].text
|
|
|
|
if number !~ /#{params[:number]}/
|
|
|
|
raise "unable to search/find ticket #{params[:number]}!"
|
|
|
|
end
|
2015-02-28 10:40:23 +00:00
|
|
|
sleep 1
|
|
|
|
true
|
2015-02-22 12:28:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
overview_count = overview_counter(
|
|
|
|
:browser => browser2,
|
|
|
|
)
|
|
|
|
|
|
|
|
returns
|
|
|
|
{
|
|
|
|
'#ticket/view/all_unassigned' => 42,
|
|
|
|
}
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def overview_counter(params = {})
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
|
|
|
instance.find_elements( { :css => '#navigation li.overviews a' } )[0].click
|
|
|
|
sleep 2
|
|
|
|
overviews = {}
|
|
|
|
instance.find_elements( { :css => '.content.active .sidebar a[href]' } ).each {|element|
|
|
|
|
url = element.attribute('href')
|
|
|
|
url.gsub!(/(http|https):\/\/.+?\/(.+?)$/, "\\2")
|
|
|
|
overviews[url] = 0
|
|
|
|
#puts url.inspect
|
|
|
|
#puts element.inspect
|
|
|
|
}
|
|
|
|
overviews.each {|url, value|
|
2015-02-28 10:40:23 +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
|
|
|
|
}
|
|
|
|
overviews
|
|
|
|
end
|
|
|
|
|
2015-02-23 13:49:40 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
organization_open_by_search(
|
|
|
|
:browser => browser2,
|
|
|
|
:value => 'some value',
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def organization_open_by_search(params = {})
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
|
|
|
element = instance.find_elements( { :css => '#global-search' } )[0]
|
|
|
|
|
|
|
|
element.click
|
|
|
|
element.clear
|
|
|
|
element.send_keys( params[:value] )
|
|
|
|
sleep 3
|
|
|
|
instance.find_elements( { :css => '.search .empty-search' } )[0].click
|
|
|
|
sleep 0.5
|
|
|
|
text = instance.find_elements( { :css => '#global-search' } )[0].attribute('value')
|
|
|
|
if !text
|
|
|
|
raise "#global-search is not empty!"
|
|
|
|
end
|
|
|
|
element = instance.find_elements( { :css => '#global-search' } )[0]
|
|
|
|
element.click
|
|
|
|
element.clear
|
|
|
|
element.send_keys( params[:value] )
|
|
|
|
sleep 2
|
|
|
|
element = instance.find_element( { :partial_link_text => params[:value] } ).click
|
|
|
|
name = instance.find_elements( { :css => '.active h1' } )[0].text
|
|
|
|
if name !~ /#{params[:value]}/
|
|
|
|
raise "unable to search/find org #{params[:value]}!"
|
|
|
|
return
|
|
|
|
end
|
|
|
|
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(
|
|
|
|
:browser => browser2,
|
|
|
|
:value => 'some value',
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def user_open_by_search(params = {})
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
|
|
|
|
element = instance.find_elements( { :css => '#global-search' } )[0]
|
|
|
|
element.click
|
|
|
|
element.clear
|
|
|
|
element.send_keys( params[:value] )
|
|
|
|
sleep 3
|
|
|
|
element = instance.find_element( { :partial_link_text => params[:value] } ).click
|
|
|
|
name = instance.find_elements( { :css => '.active h1' } )[0].text
|
|
|
|
if name !~ /#{params[:value]}/
|
|
|
|
raise "unable to search/find user #{params[:value]}!"
|
|
|
|
end
|
|
|
|
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(
|
|
|
|
:browser => browser2,
|
|
|
|
:data => {
|
|
|
|
:login => 'some login' + random,
|
|
|
|
:firstname => 'Manage Firstname' + random,
|
|
|
|
:lastname => 'Manage Lastname' + random,
|
|
|
|
:email => user_email,
|
|
|
|
:password => 'some-pass',
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def user_create(params = {})
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
data = params[:data]
|
|
|
|
|
|
|
|
instance.find_elements( { :css => 'a[href="#manage"]' } )[0].click
|
|
|
|
instance.find_elements( { :css => 'a[href="#manage/users"]' } )[0].click
|
|
|
|
sleep 2
|
|
|
|
instance.find_elements( { :css => 'a[data-type="new"]' } )[0].click
|
|
|
|
sleep 2
|
|
|
|
element = instance.find_elements( { :css => '.modal input[name=firstname]' } )[0]
|
|
|
|
element.clear
|
|
|
|
element.send_keys( data[:firstname] )
|
|
|
|
element = instance.find_elements( { :css => '.modal input[name=lastname]' } )[0]
|
|
|
|
element.clear
|
|
|
|
element.send_keys( data[:lastname] )
|
|
|
|
element = instance.find_elements( { :css => '.modal input[name=email]' } )[0]
|
|
|
|
element.clear
|
|
|
|
element.send_keys( data[:email] )
|
|
|
|
element = instance.find_elements( { :css => '.modal input[name=password]' } )[0]
|
|
|
|
element.clear
|
|
|
|
element.send_keys( data[:password] )
|
|
|
|
element = instance.find_elements( { :css => '.modal input[name=password_confirm]' } )[0]
|
|
|
|
element.clear
|
|
|
|
element.send_keys( data[:password] )
|
|
|
|
instance.find_elements( { :css => '.modal input[name="role_ids"][value="3"]' } )[0].click
|
|
|
|
instance.find_elements( { :css => '.modal button.js-submit' } )[0].click
|
|
|
|
|
|
|
|
sleep 2
|
|
|
|
set(
|
|
|
|
:browser => instance,
|
|
|
|
:css => '.content .js-search',
|
|
|
|
:value => data[:email],
|
|
|
|
)
|
|
|
|
watch_for(
|
|
|
|
:browser => instance,
|
|
|
|
:css => 'body',
|
|
|
|
:value => data[:lastname],
|
|
|
|
)
|
|
|
|
|
|
|
|
assert( true, "user created" )
|
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
sla_create(
|
|
|
|
:browser => browser2,
|
|
|
|
:data => {
|
|
|
|
:name => 'some sla' + random,
|
|
|
|
:first_response_time => 61
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def sla_create(params = {})
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
data = params[:data]
|
|
|
|
|
|
|
|
instance.find_elements( { :css => 'a[href="#manage"]' } )[0].click
|
|
|
|
instance.find_elements( { :css => 'a[href="#manage/slas"]' } )[0].click
|
|
|
|
sleep 2
|
|
|
|
instance.find_elements( { :css => 'a[data-type="new"]' } )[0].click
|
|
|
|
sleep 2
|
|
|
|
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=first_response_time]' } )[0]
|
|
|
|
element.clear
|
|
|
|
element.send_keys( data[:first_response_time] )
|
|
|
|
instance.find_elements( { :css => '.modal button.js-submit' } )[0].click
|
|
|
|
(1..8).each {|loop|
|
|
|
|
element = instance.find_elements( { :css => 'body' } )[0]
|
|
|
|
text = element.text
|
|
|
|
if text =~ /#{Regexp.quote(data[:name])}/
|
|
|
|
assert( true, "sla created" )
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
sleep 1
|
|
|
|
}
|
|
|
|
raise "sla creation failed"
|
|
|
|
end
|
|
|
|
|
2015-02-23 22:37:00 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
text_module_create(
|
|
|
|
:browser => browser2,
|
|
|
|
:data => {
|
|
|
|
:name => 'some sla' + random,
|
|
|
|
:keywords => 'some keywords',
|
|
|
|
:content => 'some content',
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def text_module_create(params = {})
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
data = params[:data]
|
|
|
|
|
|
|
|
instance.find_elements( { :css => 'a[href="#manage"]' } )[0].click
|
|
|
|
instance.find_elements( { :css => 'a[href="#manage/text_modules"]' } )[0].click
|
|
|
|
sleep 2
|
|
|
|
instance.find_elements( { :css => 'a[data-type="new"]' } )[0].click
|
|
|
|
sleep 2
|
|
|
|
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=keywords]' } )[0]
|
|
|
|
element.clear
|
|
|
|
element.send_keys( data[:keywords] )
|
|
|
|
element = instance.find_elements( { :css => '.modal textarea[name=content]' } )[0]
|
|
|
|
element.clear
|
|
|
|
element.send_keys( data[:content] )
|
|
|
|
instance.find_elements( { :css => '.modal button.js-submit' } )[0].click
|
|
|
|
(1..8).each {|loop|
|
|
|
|
element = instance.find_elements( { :css => 'body' } )[0]
|
|
|
|
text = element.text
|
|
|
|
if text =~ /#{Regexp.quote(data[:name])}/
|
|
|
|
assert( true, "text module created" )
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
sleep 1
|
|
|
|
}
|
|
|
|
raise "text module creation failed"
|
|
|
|
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(
|
|
|
|
:browser => browser2,
|
|
|
|
:data => {
|
|
|
|
:name => 'some sla' + random,
|
|
|
|
:body => 'some body',
|
|
|
|
},
|
|
|
|
)
|
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 = {})
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
data = params[:data]
|
2012-12-14 12:16:04 +00:00
|
|
|
|
2015-03-01 23:16:36 +00:00
|
|
|
instance.find_elements( { :css => 'a[href="#manage"]' } )[0].click
|
|
|
|
instance.find_elements( { :css => 'a[href="#channels/email"]' } )[0].click
|
|
|
|
instance.find_elements( { :css => 'a[href="#c-signature"]' } )[0].click
|
|
|
|
sleep 8
|
|
|
|
instance.find_elements( { :css => '#content #c-signature a[data-type="new"]' } )[0].click
|
|
|
|
sleep 2
|
|
|
|
element = instance.find_elements( { :css => '.modal input[name=name]' } )[0]
|
|
|
|
element.clear
|
|
|
|
element.send_keys( data[:name] )
|
|
|
|
element = instance.find_elements( { :css => '.modal textarea[name=body]' } )[0]
|
|
|
|
element.clear
|
|
|
|
element.send_keys( data[:body] )
|
|
|
|
instance.find_elements( { :css => '.modal button.js-submit' } )[0].click
|
|
|
|
(1..12).each {|loop|
|
|
|
|
element = instance.find_elements( { :css => 'body' } )[0]
|
|
|
|
text = element.text
|
|
|
|
if text =~ /#{Regexp.quote(data[:name])}/
|
|
|
|
assert( true, "signature created" )
|
|
|
|
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-03-01 23:16:36 +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(
|
|
|
|
:browser => browser2,
|
|
|
|
:data => {
|
|
|
|
:name => 'some sla' + random,
|
|
|
|
:signature => 'some signature bame',
|
|
|
|
:member => [
|
|
|
|
'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 = {})
|
|
|
|
instance = params[:browser] || @browser
|
|
|
|
data = params[:data]
|
2015-01-23 22:24:03 +00:00
|
|
|
|
2015-03-01 23:16:36 +00:00
|
|
|
instance.find_elements( { :css => 'a[href="#manage"]' } )[0].click
|
|
|
|
instance.find_elements( { :css => 'a[href="#manage/groups"]' } )[0].click
|
|
|
|
sleep 2
|
|
|
|
instance.find_elements( { :css => 'a[data-type="new"]' } )[0].click
|
|
|
|
sleep 2
|
|
|
|
element = instance.find_elements( { :css => '.modal input[name=name]' } )[0]
|
|
|
|
element.clear
|
|
|
|
element.send_keys( data[:name] )
|
|
|
|
element = instance.find_elements( { :css => '.modal select[name="email_address_id"]' } )[0]
|
|
|
|
dropdown = Selenium::WebDriver::Support::Select.new(element)
|
|
|
|
dropdown.select_by( :index, 1 )
|
|
|
|
#dropdown.select_by( :text, action[:group])
|
|
|
|
if data[:signature]
|
|
|
|
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-03-01 23:16:36 +00:00
|
|
|
dropdown.select_by( :text, data[:signature])
|
2012-12-14 12:16:04 +00:00
|
|
|
end
|
2015-03-01 23:16:36 +00:00
|
|
|
instance.find_elements( { :css => '.modal button.js-submit' } )[0].click
|
|
|
|
(1..12).each {|loop|
|
|
|
|
element = instance.find_elements( { :css => 'body' } )[0]
|
|
|
|
text = element.text
|
|
|
|
if text =~ /#{Regexp.quote(data[:name])}/
|
|
|
|
assert( true, "group created" )
|
|
|
|
|
|
|
|
# add member
|
|
|
|
if data[:member]
|
|
|
|
data[:member].each {|login|
|
|
|
|
instance.find_elements( { :css => 'a[href="#manage"]' } )[0].click
|
|
|
|
instance.find_elements( { :css => 'a[href="#manage/users"]' } )[0].click
|
|
|
|
sleep 2
|
|
|
|
element = instance.find_elements( { :css => '#content [name="search"]' } )[0]
|
|
|
|
element.clear
|
|
|
|
element.send_keys( login )
|
|
|
|
sleep 2
|
|
|
|
#instance.find_elements( { :css => '#content table [data-id]' } )[0].click
|
|
|
|
instance.execute_script( '$("#content table [data-id] td").first().click()' )
|
|
|
|
sleep 2
|
|
|
|
#instance.find_elements( { :css => 'label:contains(" ' + action[:name] + '")' } )[0].click
|
|
|
|
instance.execute_script( '$(\'label:contains(" ' + data[:name] + '")\').first().click()' )
|
|
|
|
instance.find_elements( { :css => '.modal button.js-submit' } )[0].click
|
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
|
|
|
|
}
|
|
|
|
raise "group creation failed"
|
2012-12-14 12:16:04 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
end
|