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
|
def test_org_profile
|
||||||
# work in one browser window
|
# work in one browser window
|
||||||
message = '1 ' + rand(99999999).to_s
|
message = '1 ' + rand(99999999).to_s
|
||||||
|
note = 'some note ' + rand(99999999).to_s
|
||||||
|
|
||||||
@browser = browser_instance
|
@browser = browser_instance
|
||||||
login(
|
login(
|
||||||
|
@ -29,10 +30,12 @@ class AgentOrganizationProfileTest < TestCase
|
||||||
|
|
||||||
# update note
|
# update note
|
||||||
set(
|
set(
|
||||||
:css => '.active [data-name="note"]',
|
:css => '.active .profile [data-name="note"]',
|
||||||
:value => 'some note 123'
|
:value => note,
|
||||||
|
:contenteditable => true,
|
||||||
)
|
)
|
||||||
click( :css => '.active .profile' )
|
click( :css => '#global-search' )
|
||||||
|
sleep 2
|
||||||
|
|
||||||
# check and change note again in edit screen
|
# check and change note again in edit screen
|
||||||
click( :css => '.active .js-action .select-arrow' )
|
click( :css => '.active .js-action .select-arrow' )
|
||||||
|
@ -44,7 +47,7 @@ class AgentOrganizationProfileTest < TestCase
|
||||||
)
|
)
|
||||||
watch_for(
|
watch_for(
|
||||||
:css => '.active .modal',
|
:css => '.active .modal',
|
||||||
:value => 'some note 123',
|
:value => note,
|
||||||
)
|
)
|
||||||
|
|
||||||
set(
|
set(
|
||||||
|
@ -108,13 +111,14 @@ class AgentOrganizationProfileTest < TestCase
|
||||||
|
|
||||||
# update note
|
# update note
|
||||||
set(
|
set(
|
||||||
:browser => browser1,
|
:browser => browser1,
|
||||||
:css => '.active [data-name="note"]',
|
:css => '.active .profile [data-name="note"]',
|
||||||
:value => message,
|
:value => message,
|
||||||
|
:contenteditable => true,
|
||||||
)
|
)
|
||||||
click(
|
click(
|
||||||
:browser => browser1,
|
:browser => browser1,
|
||||||
:css => '.active .profile',
|
:css => '#global-search',
|
||||||
)
|
)
|
||||||
|
|
||||||
# verify
|
# verify
|
||||||
|
|
|
@ -27,11 +27,12 @@ class AgentUserProfileTest < TestCase
|
||||||
|
|
||||||
# update note
|
# update note
|
||||||
set(
|
set(
|
||||||
:css => '.active [data-name="note"]',
|
:css => '.active [data-name="note"]',
|
||||||
:value => 'some note 123',
|
:value => 'some note 123',
|
||||||
)
|
:contenteditable => true,
|
||||||
|
|
||||||
click( :css => '.active .profile' )
|
)
|
||||||
|
click( :css => '#global-search' )
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
# check and change note again in edit screen
|
# check and change note again in edit screen
|
||||||
|
@ -106,13 +107,14 @@ class AgentUserProfileTest < TestCase
|
||||||
|
|
||||||
# update note
|
# update note
|
||||||
set(
|
set(
|
||||||
:browser => browser1,
|
:browser => browser1,
|
||||||
:css => '.active [data-name="note"]',
|
:css => '.active [data-name="note"]',
|
||||||
:value => message,
|
:value => message,
|
||||||
|
:contenteditable => true,
|
||||||
)
|
)
|
||||||
click(
|
click(
|
||||||
:browser => browser1,
|
:browser => browser1,
|
||||||
:css => '.active .profile',
|
:css => '#global-search',
|
||||||
)
|
)
|
||||||
|
|
||||||
watch_for(
|
watch_for(
|
||||||
|
|
|
@ -235,11 +235,13 @@ class TestCase < Test::Unit::TestCase
|
||||||
=begin
|
=begin
|
||||||
|
|
||||||
set(
|
set(
|
||||||
:browser => browser1,
|
:browser => browser1,
|
||||||
:css => '.some_class',
|
:css => '.some_class',
|
||||||
:value => true,
|
:value => true,
|
||||||
:slow => false,
|
:slow => false,
|
||||||
:clear => true, # todo
|
:blur => true,
|
||||||
|
:clear => true, # todo | default: true
|
||||||
|
:contenteditable => true
|
||||||
)
|
)
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
@ -247,7 +249,16 @@ class TestCase < Test::Unit::TestCase
|
||||||
def set(params)
|
def set(params)
|
||||||
instance = params[:browser] || @browser
|
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 = instance.find_elements( { :css => params[:css] } )[0]
|
||||||
|
#element.click
|
||||||
element.clear
|
element.clear
|
||||||
|
|
||||||
if !params[:slow]
|
if !params[:slow]
|
||||||
|
@ -259,6 +270,10 @@ class TestCase < Test::Unit::TestCase
|
||||||
instance.action.send_keys(key).perform
|
instance.action.send_keys(key).perform
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if params[:blur]
|
||||||
|
instance.execute_script( "$('#{params[:css]}').blur()" )
|
||||||
|
end
|
||||||
sleep 0.5
|
sleep 0.5
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue