Improved browser form tests.

This commit is contained in:
Martin Edenhofer 2016-12-01 00:30:45 +01:00
parent c706306d09
commit b2434c1a38
2 changed files with 59 additions and 21 deletions

View file

@ -52,10 +52,14 @@ class FormTest < TestCase
browser: agent, browser: agent,
css: 'body div.zammad-form-modal button[type="submit"]', css: 'body div.zammad-form-modal button[type="submit"]',
) )
exists( watch_for(
browser: agent, browser: agent,
css: 'body div.zammad-form-modal .has-error [name="body"]', css: 'body div.zammad-form-modal .has-error [name="body"]',
) )
watch_for_disappear(
browser: agent,
css: 'body div.zammad-form-modal button[type="submit"][disabled]',
)
set( set(
browser: agent, browser: agent,
css: 'body div.zammad-form-modal [name="body"]', css: 'body div.zammad-form-modal [name="body"]',
@ -70,10 +74,14 @@ class FormTest < TestCase
browser: agent, browser: agent,
css: 'body div.zammad-form-modal button[type="submit"]', css: 'body div.zammad-form-modal button[type="submit"]',
) )
exists( watch_for(
browser: agent, browser: agent,
css: 'body div.zammad-form-modal .has-error [name="email"]', css: 'body div.zammad-form-modal .has-error [name="email"]',
) )
watch_for_disappear(
browser: agent,
css: 'body div.zammad-form-modal button[type="submit"][disabled]',
)
set( set(
browser: agent, browser: agent,
css: 'body div.zammad-form-modal [name="email"]', css: 'body div.zammad-form-modal [name="email"]',
@ -83,10 +91,14 @@ class FormTest < TestCase
browser: agent, browser: agent,
css: 'body div.zammad-form-modal button[type="submit"]', css: 'body div.zammad-form-modal button[type="submit"]',
) )
exists( watch_for(
browser: agent, browser: agent,
css: 'body div.zammad-form-modal .has-error [name="email"]', css: 'body div.zammad-form-modal .has-error [name="email"]',
) )
watch_for_disappear(
browser: agent,
css: 'body div.zammad-form-modal button[type="submit"][disabled]',
)
set( set(
browser: agent, browser: agent,
css: 'body div.zammad-form-modal [name="email"]', css: 'body div.zammad-form-modal [name="email"]',
@ -111,8 +123,7 @@ class FormTest < TestCase
browser: customer, browser: customer,
url: "#{browser_url}/assets/form/form.html", url: "#{browser_url}/assets/form/form.html",
) )
sleep 4 watch_for(
match(
browser: customer, browser: customer,
css: '.js-logDisplay', css: '.js-logDisplay',
value: 'Faild to load form config, feature is disabled', value: 'Faild to load form config, feature is disabled',
@ -143,7 +154,7 @@ class FormTest < TestCase
browser: customer, browser: customer,
css: '#feedback-form-modal', css: '#feedback-form-modal',
) )
exists( watch_for(
browser: customer, browser: customer,
css: 'body div.zammad-form-modal', css: 'body div.zammad-form-modal',
) )
@ -252,10 +263,14 @@ class FormTest < TestCase
browser: customer, browser: customer,
css: 'body div.zammad-form-modal button[type="submit"]', css: 'body div.zammad-form-modal button[type="submit"]',
) )
exists( watch_for(
browser: customer, browser: customer,
css: 'body div.zammad-form-modal .has-error [name="name"]', css: 'body div.zammad-form-modal .has-error [name="name"]',
) )
watch_for_disappear(
browser: customer,
css: 'body div.zammad-form-modal button[type="submit"][disabled]',
)
set( set(
browser: customer, browser: customer,
css: 'body div.zammad-form-modal [name="name"]', css: 'body div.zammad-form-modal [name="name"]',
@ -270,10 +285,14 @@ class FormTest < TestCase
browser: customer, browser: customer,
css: 'body div.zammad-form-modal button[type="submit"]', css: 'body div.zammad-form-modal button[type="submit"]',
) )
exists( watch_for(
browser: customer, browser: customer,
css: 'body div.zammad-form-modal .has-error [name="body"]', css: 'body div.zammad-form-modal .has-error [name="body"]',
) )
watch_for_disappear(
browser: customer,
css: 'body div.zammad-form-modal button[type="submit"][disabled]',
)
set( set(
browser: customer, browser: customer,
css: 'body div.zammad-form-modal [name="body"]', css: 'body div.zammad-form-modal [name="body"]',
@ -288,10 +307,14 @@ class FormTest < TestCase
browser: customer, browser: customer,
css: 'body div.zammad-form-modal button[type="submit"]', css: 'body div.zammad-form-modal button[type="submit"]',
) )
exists( watch_for(
browser: customer, browser: customer,
css: 'body div.zammad-form-modal .has-error [name="email"]', css: 'body div.zammad-form-modal .has-error [name="email"]',
) )
watch_for_disappear(
browser: customer,
css: 'body div.zammad-form-modal button[type="submit"][disabled]',
)
set( set(
browser: customer, browser: customer,
css: 'body div.zammad-form-modal [name="email"]', css: 'body div.zammad-form-modal [name="email"]',
@ -301,10 +324,14 @@ class FormTest < TestCase
browser: customer, browser: customer,
css: 'body div.zammad-form-modal button[type="submit"]', css: 'body div.zammad-form-modal button[type="submit"]',
) )
exists( watch_for(
browser: customer, browser: customer,
css: 'body div.zammad-form-modal .has-error [name="email"]', css: 'body div.zammad-form-modal .has-error [name="email"]',
) )
watch_for_disappear(
browser: customer,
css: 'body div.zammad-form-modal button[type="submit"][disabled]',
)
set( set(
browser: customer, browser: customer,
css: 'body div.zammad-form-modal [name="email"]', css: 'body div.zammad-form-modal [name="email"]',

View file

@ -1240,18 +1240,26 @@ class TestCase < Test::Unit::TestCase
if element #&& element.displayed? if element #&& element.displayed?
begin begin
# match pn attribute # watch for selector
text = if params[:attribute] if !params[:attribute] && !params[:value]
element.attribute(params[:attribute]) assert(true, "'#{params[:css]}' found")
elsif params[:css] =~ /(input|textarea)/i
element.attribute('value')
else
element.text
end
if text =~ /#{params[:value]}/i
assert(true, "'#{params[:value]}' found in '#{text}'")
sleep 0.5 sleep 0.5
return true return true
# match pn attribute
else
text = if params[:attribute]
element.attribute(params[:attribute])
elsif params[:css] =~ /(input|textarea)/i
element.attribute('value')
else
element.text
end
if text =~ /#{params[:value]}/i
assert(true, "'#{params[:value]}' found in '#{text}'")
sleep 0.5
return true
end
end end
rescue rescue
# try again # try again
@ -1260,7 +1268,10 @@ class TestCase < Test::Unit::TestCase
sleep 0.5 sleep 0.5
} }
screenshot(browser: instance, comment: 'watch_for_failed') screenshot(browser: instance, comment: 'watch_for_failed')
raise "'#{params[:value]}' found in '#{text}'" if !params[:attribute] && !params[:value]
raise "'#{params[:css]}' not found"
end
raise "'#{params[:value]}' not found in '#{text}'"
end end
=begin =begin