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

View file

@ -1240,18 +1240,26 @@ class TestCase < Test::Unit::TestCase
if element #&& element.displayed?
begin
# match pn attribute
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}'")
# watch for selector
if !params[:attribute] && !params[:value]
assert(true, "'#{params[:css]}' found")
sleep 0.5
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
rescue
# try again
@ -1260,7 +1268,10 @@ class TestCase < Test::Unit::TestCase
sleep 0.5
}
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
=begin