Fixed file upload on remote browsers.
This commit is contained in:
parent
5d4876a5e5
commit
b066064ec9
1 changed files with 25 additions and 24 deletions
|
@ -69,6 +69,12 @@ class TestCase < Test::Unit::TestCase
|
||||||
browser_instance_preferences(local_browser)
|
browser_instance_preferences(local_browser)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# upload files from remote dir
|
||||||
|
local_browser.file_detector = lambda do |args|
|
||||||
|
str = args.first.to_s
|
||||||
|
str if File.file?(str)
|
||||||
|
end
|
||||||
|
|
||||||
local_browser
|
local_browser
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -88,11 +94,6 @@ class TestCase < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local_browser.manage.timeouts.implicit_wait = 3 # seconds
|
local_browser.manage.timeouts.implicit_wait = 3 # seconds
|
||||||
|
|
||||||
local_browser.file_detector = lambda do |args|
|
|
||||||
str = args.first.to_s
|
|
||||||
str if File.exist?(str)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
|
@ -129,37 +130,37 @@ class TestCase < Test::Unit::TestCase
|
||||||
instance = params[:browser] || @browser
|
instance = params[:browser] || @browser
|
||||||
|
|
||||||
if params[:url]
|
if params[:url]
|
||||||
instance.get(params[:url] )
|
instance.get(params[:url])
|
||||||
end
|
end
|
||||||
|
|
||||||
element = instance.find_elements({ css: '#login input[name="username"]' } )[0]
|
element = instance.find_elements({ css: '#login input[name="username"]' })[0]
|
||||||
if !element
|
if !element
|
||||||
screenshot(browser: instance, comment: 'login_failed' )
|
screenshot(browser: instance, comment: 'login_failed')
|
||||||
fail 'No login box found'
|
fail 'No login box found'
|
||||||
end
|
end
|
||||||
|
|
||||||
screenshot(browser: instance, comment: 'login' )
|
screenshot(browser: instance, comment: 'login')
|
||||||
|
|
||||||
element.clear
|
element.clear
|
||||||
element.send_keys(params[:username] )
|
element.send_keys(params[:username])
|
||||||
|
|
||||||
element = instance.find_elements({ css: '#login input[name="password"]' } )[0]
|
element = instance.find_elements({ css: '#login input[name="password"]' })[0]
|
||||||
element.clear
|
element.clear
|
||||||
element.send_keys(params[:password] )
|
element.send_keys(params[:password])
|
||||||
|
|
||||||
if params[:remember_me]
|
if params[:remember_me]
|
||||||
instance.find_elements({ css: '#login .checkbox-replacement' } )[0].click
|
instance.find_elements({ css: '#login .checkbox-replacement' })[0].click
|
||||||
end
|
end
|
||||||
instance.find_elements({ css: '#login button' } )[0].click
|
instance.find_elements({ css: '#login button' })[0].click
|
||||||
|
|
||||||
sleep 5
|
sleep 5
|
||||||
login = instance.find_elements({ css: '.user-menu .user a' } )[0].attribute('title')
|
login = instance.find_elements({ css: '.user-menu .user a' })[0].attribute('title')
|
||||||
if login != params[:username]
|
if login != params[:username]
|
||||||
screenshot(browser: instance, comment: 'login_failed' )
|
screenshot(browser: instance, comment: 'login_failed')
|
||||||
fail 'login failed'
|
fail 'login failed'
|
||||||
end
|
end
|
||||||
screenshot(browser: instance, comment: 'login_ok' )
|
screenshot(browser: instance, comment: 'login_ok')
|
||||||
assert(true, 'login ok' )
|
assert(true, 'login ok')
|
||||||
login
|
login
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -177,19 +178,19 @@ class TestCase < Test::Unit::TestCase
|
||||||
|
|
||||||
instance = params[:browser] || @browser
|
instance = params[:browser] || @browser
|
||||||
|
|
||||||
instance.find_elements({ css: 'a[href="#current_user"]' } )[0].click
|
instance.find_elements({ css: 'a[href="#current_user"]' })[0].click
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
instance.find_elements({ css: 'a[href="#logout"]' } )[0].click
|
instance.find_elements({ css: 'a[href="#logout"]' })[0].click
|
||||||
(1..6).each {
|
(1..6).each {
|
||||||
sleep 1
|
sleep 1
|
||||||
login = instance.find_elements({ css: '#login' } )[0]
|
login = instance.find_elements({ css: '#login' })[0]
|
||||||
|
|
||||||
next if !login
|
next if !login
|
||||||
screenshot(browser: instance, comment: 'logout_ok' )
|
screenshot(browser: instance, comment: 'logout_ok')
|
||||||
assert(true, 'logout ok' )
|
assert(true, 'logout ok')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
screenshot(browser: instance, comment: 'logout_failed' )
|
screenshot(browser: instance, comment: 'logout_failed')
|
||||||
fail 'no login box found, seems logout was not successfully!'
|
fail 'no login box found, seems logout was not successfully!'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue