Improved error handling of content editable fields.

This commit is contained in:
Martin Edenhofer 2015-02-26 13:41:09 +01:00
parent 1c9d00f5c4
commit 3d0f76cea0
3 changed files with 42 additions and 21 deletions

View file

@ -5,6 +5,7 @@ class AgentOrganizationProfileTest < TestCase
def test_org_profile
# work in one browser window
message = '1 ' + rand(99999999).to_s
note = 'some note ' + rand(99999999).to_s
@browser = browser_instance
login(
@ -29,10 +30,12 @@ class AgentOrganizationProfileTest < TestCase
# update note
set(
:css => '.active [data-name="note"]',
:value => 'some note 123'
:css => '.active .profile [data-name="note"]',
:value => note,
:contenteditable => true,
)
click( :css => '.active .profile' )
click( :css => '#global-search' )
sleep 2
# check and change note again in edit screen
click( :css => '.active .js-action .select-arrow' )
@ -44,7 +47,7 @@ class AgentOrganizationProfileTest < TestCase
)
watch_for(
:css => '.active .modal',
:value => 'some note 123',
:value => note,
)
set(
@ -109,12 +112,13 @@ class AgentOrganizationProfileTest < TestCase
# update note
set(
:browser => browser1,
:css => '.active [data-name="note"]',
:css => '.active .profile [data-name="note"]',
:value => message,
:contenteditable => true,
)
click(
:browser => browser1,
:css => '.active .profile',
:css => '#global-search',
)
# verify

View file

@ -29,9 +29,10 @@ class AgentUserProfileTest < TestCase
set(
:css => '.active [data-name="note"]',
:value => 'some note 123',
)
:contenteditable => true,
click( :css => '.active .profile' )
)
click( :css => '#global-search' )
sleep 2
# check and change note again in edit screen
@ -109,10 +110,11 @@ class AgentUserProfileTest < TestCase
:browser => browser1,
:css => '.active [data-name="note"]',
:value => message,
:contenteditable => true,
)
click(
:browser => browser1,
:css => '.active .profile',
:css => '#global-search',
)
watch_for(

View file

@ -239,7 +239,9 @@ class TestCase < Test::Unit::TestCase
:css => '.some_class',
:value => true,
:slow => false,
:clear => true, # todo
:blur => true,
:clear => true, # todo | default: true
:contenteditable => true
)
=end
@ -247,7 +249,16 @@ class TestCase < Test::Unit::TestCase
def set(params)
instance = params[:browser] || @browser
# it's not working stable via selenium, use js
if params[:contenteditable]
#puts "---$('#{params[:css]}').html('#{params[:value]}')--"
instance.execute_script( "$('#{params[:css]}').focus().html('#{params[:value]}').trigger('change').blur()" )
sleep 1
return
end
element = instance.find_elements( { :css => params[:css] } )[0]
#element.click
element.clear
if !params[:slow]
@ -259,6 +270,10 @@ class TestCase < Test::Unit::TestCase
instance.action.send_keys(key).perform
}
end
if params[:blur]
instance.execute_script( "$('#{params[:css]}').blur()" )
end
sleep 0.5
end