Improved error handling of content editable fields.
This commit is contained in:
parent
1c9d00f5c4
commit
3d0f76cea0
3 changed files with 42 additions and 21 deletions
|
@ -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(
|
||||
|
@ -108,13 +111,14 @@ class AgentOrganizationProfileTest < TestCase
|
|||
|
||||
# update note
|
||||
set(
|
||||
:browser => browser1,
|
||||
:css => '.active [data-name="note"]',
|
||||
:value => message,
|
||||
:browser => browser1,
|
||||
:css => '.active .profile [data-name="note"]',
|
||||
:value => message,
|
||||
:contenteditable => true,
|
||||
)
|
||||
click(
|
||||
:browser => browser1,
|
||||
:css => '.active .profile',
|
||||
:css => '#global-search',
|
||||
)
|
||||
|
||||
# verify
|
||||
|
|
|
@ -27,11 +27,12 @@ class AgentUserProfileTest < TestCase
|
|||
|
||||
# update note
|
||||
set(
|
||||
:css => '.active [data-name="note"]',
|
||||
:value => 'some note 123',
|
||||
)
|
||||
: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
|
||||
|
@ -106,13 +107,14 @@ class AgentUserProfileTest < TestCase
|
|||
|
||||
# update note
|
||||
set(
|
||||
:browser => browser1,
|
||||
:css => '.active [data-name="note"]',
|
||||
:value => message,
|
||||
:browser => browser1,
|
||||
:css => '.active [data-name="note"]',
|
||||
:value => message,
|
||||
:contenteditable => true,
|
||||
)
|
||||
click(
|
||||
:browser => browser1,
|
||||
:css => '.active .profile',
|
||||
:css => '#global-search',
|
||||
)
|
||||
|
||||
watch_for(
|
||||
|
|
|
@ -235,11 +235,13 @@ class TestCase < Test::Unit::TestCase
|
|||
=begin
|
||||
|
||||
set(
|
||||
:browser => browser1,
|
||||
:css => '.some_class',
|
||||
:value => true,
|
||||
:slow => false,
|
||||
:clear => true, # todo
|
||||
:browser => browser1,
|
||||
:css => '.some_class',
|
||||
:value => true,
|
||||
:slow => false,
|
||||
: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
|
||||
|
||||
|
|
Loading…
Reference in a new issue