Commit 946300125782da84533147e0f834adb6eafb0ab5
1 parent
d34432ad
Exists in
master
and in
14 other branches
web_steps: retry filling in tinyMCE for up to 5 seconds
Depending on timing trying to fill a tinyMCE control will fail with `tinymce.editors.article_body is undefined` (Selenium::WebDriver::Error::JavascriptError), probably because at the point we try to interact with the editor it is still being loaded by the browser. Because of that in case of failure we sleep for 1 second and try again at most 5 times.
Showing
1 changed file
with
12 additions
and
1 deletions
Show diff stats
features/step_definitions/web_steps.rb
| @@ -277,7 +277,18 @@ Then /^display "([^\"]*)"$/ do |element| | @@ -277,7 +277,18 @@ Then /^display "([^\"]*)"$/ do |element| | ||
| 277 | end | 277 | end |
| 278 | 278 | ||
| 279 | Then /^I fill in tinyMCE "(.*?)" with "(.*?)"$/ do |field, content| | 279 | Then /^I fill in tinyMCE "(.*?)" with "(.*?)"$/ do |field, content| |
| 280 | - execute_script("$(tinymce.editors['#{field}'].setContent('#{content}'))") | 280 | + n = 0 |
| 281 | + begin | ||
| 282 | + execute_script("tinymce.editors['#{field}'].setContent('#{content}')") | ||
| 283 | + rescue Selenium::WebDriver::Error::JavascriptError | ||
| 284 | + n += 1 | ||
| 285 | + if n < 5 | ||
| 286 | + sleep 1 | ||
| 287 | + retry | ||
| 288 | + else | ||
| 289 | + raise | ||
| 290 | + end | ||
| 291 | + end | ||
| 281 | end | 292 | end |
| 282 | 293 | ||
| 283 | Then /^there should be a div with class "([^"]*)"$/ do |klass| | 294 | Then /^there should be a div with class "([^"]*)"$/ do |klass| |