Added safari alert() support.

This commit is contained in:
Martin Edenhofer 2013-06-10 13:12:39 +02:00
parent 5a5a334505
commit 4d321a996c

View file

@ -161,6 +161,7 @@ class TestCase < Test::Unit::TestCase
def browser_element_action(test, action, instance) def browser_element_action(test, action, instance)
if action[:css] if action[:css]
# puts "NOTICE: css #{ action[:css] }"
begin begin
if action[:range] == 'all' if action[:range] == 'all'
element = instance.find_elements( { :css => action[:css] } ) element = instance.find_elements( { :css => action[:css] } )
@ -182,6 +183,7 @@ class TestCase < Test::Unit::TestCase
assert( false, "(#{test[:name]}) url #{instance.current_url} is not matching #{action[:result]}" ) assert( false, "(#{test[:name]}) url #{instance.current_url} is not matching #{action[:result]}" )
end end
elsif action[:element] == :alert elsif action[:element] == :alert
puts "laalal"
element = instance.switch_to.alert element = instance.switch_to.alert
elsif action[:execute] == 'close_all_tasks' elsif action[:execute] == 'close_all_tasks'
while true while true
@ -213,6 +215,9 @@ class TestCase < Test::Unit::TestCase
dropdown = Selenium::WebDriver::Support::Select.new(element) dropdown = Selenium::WebDriver::Support::Select.new(element)
dropdown.select_by(:text, action[:value]) dropdown.select_by(:text, action[:value])
elsif action[:execute] == 'click' elsif action[:execute] == 'click'
# ignore alert clicks on safari / not supported
if action[:element] != :alert || ( action[:element] == :alert && ENV['BROWSER'] !~ /safari/i )
if element.class == Array if element.class == Array
element.each {|item| element.each {|item|
item.click item.click
@ -220,6 +225,7 @@ class TestCase < Test::Unit::TestCase
else else
element.click element.click
end end
end
elsif action[:execute] == 'accept' elsif action[:execute] == 'accept'
element.accept element.accept
elsif action[:execute] == 'dismiss' elsif action[:execute] == 'dismiss'