[Git][noosfero/noosfero][master] web_steps: retry filling in tinyMCE for up to 5 seconds

Antonio Terceiro gitlab at mg.gitlab.com
Thu Feb 4 16:29:08 BRST 2016


Antonio Terceiro pushed to branch master at Noosfero / noosfero


Commits:
94630012 by Antonio Terceiro at 2016-02-04T16:28:23-02:00
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.

- - - - -


1 changed file:

- features/step_definitions/web_steps.rb


Changes:

=====================================
features/step_definitions/web_steps.rb
=====================================
--- a/features/step_definitions/web_steps.rb
+++ b/features/step_definitions/web_steps.rb
@@ -277,7 +277,18 @@ Then /^display "([^\"]*)"$/ do |element|
 end
 
 Then /^I fill in tinyMCE "(.*?)" with "(.*?)"$/ do |field, content|
-  execute_script("$(tinymce.editors['#{field}'].setContent('#{content}'))")
+  n = 0
+  begin
+    execute_script("tinymce.editors['#{field}'].setContent('#{content}')")
+  rescue Selenium::WebDriver::Error::JavascriptError
+    n += 1
+    if n < 5
+      sleep 1
+      retry
+    else
+      raise
+    end
+  end
 end
 
 Then /^there should be a div with class "([^"]*)"$/ do |klass|



View it on GitLab: https://gitlab.com/noosfero/noosfero/commit/946300125782da84533147e0f834adb6eafb0ab5
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20160204/41940253/attachment.html>


More information about the Noosfero-dev mailing list