Improved browser helper click() - scroll to element before click (needed for chrome behaves).

This commit is contained in:
Martin Edenhofer 2015-11-17 10:03:51 +01:00
parent 787553ea42
commit 5c085b128c
2 changed files with 62 additions and 26 deletions

View file

@ -30,7 +30,6 @@ class AgentTicketOverviewLevel0Test < TestCase
body: 'overview count test #2',
}
)
sleep 6 # till overview is updated
click( text: 'Overviews' )
# enable full overviews
@ -39,7 +38,7 @@ class AgentTicketOverviewLevel0Test < TestCase
)
click( text: 'Unassigned & Open' )
sleep 4 # till overview is rendered
sleep 6 # till overview is rendered
# select both via bulk action
click(
@ -50,6 +49,7 @@ class AgentTicketOverviewLevel0Test < TestCase
css: '.active table tr td input[value="' + ticket2[:id] + '"] + .icon-checkbox.icon-unchecked',
fast: true,
)
exists(
css: '.active table tr td input[value="' + ticket1[:id] + '"][type="checkbox"]:checked',
)
@ -68,7 +68,7 @@ class AgentTicketOverviewLevel0Test < TestCase
click(
css: '.active .bulkAction .js-submit',
)
sleep 6
sleep 4
exists_not(
css: '.active table tr td input[value="' + ticket1[:id] + '"]',
@ -154,7 +154,7 @@ class AgentTicketOverviewLevel0Test < TestCase
css: '.modal input[value="article_count"]',
)
click( css: '.modal .js-submit' )
sleep 4
sleep 2
# check if number and article count is gone
match_not(
@ -178,7 +178,7 @@ class AgentTicketOverviewLevel0Test < TestCase
body: 'overview count test #3',
}
)
sleep 8
sleep 6
# get new overview count
overview_counter_new = overview_counter()
@ -196,7 +196,7 @@ class AgentTicketOverviewLevel0Test < TestCase
state: 'closed',
}
)
sleep 8
sleep 6
# get current overview count
overview_counter_after = overview_counter()

View file

@ -101,11 +101,11 @@ class TestCase < Test::Unit::TestCase
=begin
username = login(
:browser => browser1,
:username => 'someuser',
:password => 'somepassword',
:url => 'some url', # optional
:remember_me => true, # optional
browser: browser1,
username: 'someuser',
password: 'somepassword',
url: 'some url', # optional
remember_me: true, # optional
)
=end
@ -152,7 +152,7 @@ class TestCase < Test::Unit::TestCase
=begin
logout(
:browser => browser1
browser: browser1
)
=end
@ -181,8 +181,8 @@ class TestCase < Test::Unit::TestCase
=begin
location(
:browser => browser1,
:url => 'http://someurl',
browser: browser1,
url: 'http://someurl',
)
=end
@ -198,8 +198,8 @@ class TestCase < Test::Unit::TestCase
=begin
location_check(
:browser => browser1,
:url => 'http://someurl',
browser: browser1,
url: 'http://someurl',
)
=end
@ -218,7 +218,7 @@ class TestCase < Test::Unit::TestCase
=begin
reload(
:browser => browser1,
browser: browser1,
)
=end
@ -235,15 +235,15 @@ class TestCase < Test::Unit::TestCase
=begin
click(
:browser => browser1,
:css => '.some_class',
:fast => false, # do not wait
browser: browser1,
css: '.some_class',
fast: false, # do not wait
)
click(
:browser => browser1,
:text => '.partial_link_text',
:fast => false, # do not wait
browser: browser1,
text: '.partial_link_text',
fast: false, # do not wait
)
=end
@ -253,7 +253,16 @@ class TestCase < Test::Unit::TestCase
instance = params[:browser] || @browser
if params[:css]
instance.find_elements( { css: params[:css] } )[0].click
scroll_to(
browser: instance,
css: params[:css],
mute_log: true,
)
element = instance.find_elements( { css: params[:css] } )[0]
instance.mouse.move_to(element)
element.click
# trigger also focus on input/select and textarea fields
#if params[:css] =~ /(input|select|textarea)/
@ -266,11 +275,33 @@ class TestCase < Test::Unit::TestCase
sleep 0.4 if !params[:fast]
end
=begin
scroll_to(
browser: browser1,
css: '.some_class',
)
=end
def scroll_to(params)
log('scroll_to', params)
instance = params[:browser] || @browser
execute(
browser: instance,
js: "\$('#{params[:css]}').get(0).scrollIntoView(true)",
mute_log: params[:mute_log]
)
sleep 0.4
end
=begin
execute(
:browser => browser1,
:js => '.some_class',
browser: browser1,
js: '.some_class',
)
=end
@ -1521,6 +1552,10 @@ wait untill text in selector disabppears
browser: instance,
js: '$(".content.active .sidebar").css("display", "block")',
)
#execute(
# browser: instance,
# js: '$(".content.active .overview-header").css("display", "none")',
#)
overviews = {}
instance.find_elements( { css: '.content.active .sidebar a[href]' } ).each {|element|
@ -1892,6 +1927,7 @@ wait untill text in selector disabppears
def log(method, params)
return if !@@debug
return if params[:mute_log]
puts "#{Time.zone.now}/#{method}: #{params.inspect}"
end
end