Permalink
Browse files

Pages: Handle tinymce in fill_field for PhantomJS.

  • Loading branch information...
1 parent 96461f8 commit 2f3dd61e58b77fcc716f2f2cae7351f144eec962 @jone jone committed Mar 23, 2013
Showing with 9 additions and 4 deletions.
  1. +9 −4 ftw/testing/pages.py
View
@@ -209,10 +209,15 @@ def fill_field(self, label, value):
label, str(map(lambda item: item.outer_html, fields)))
if 'mce_editable' in fields.first['class'].split(' ') and \
- self.iframes_supported:
- # oh gosh, its tinymce
- with browser().get_iframe('%s_ifr' % fields.first['name']) as frame:
- frame.find_by_xpath('//body').first.type(value)
+ self.javascript_supported:
+
+ # Typing in the iframe does not work with PhantomJS.
+ # Because of this and because we need to have a consistent input
+ # value (=HTML) we just set the HTML content in TinyMCE by
+ # using JavaScript.
+ jscode = 'tinyMCE.getInstanceById("%s").setContent("%s");' % (
+ fields.first['name'], value.replace('"', '\"'))
+ browser().execute_script(jscode)
else:
browser().fill_form({fields.first['name']: value})

0 comments on commit 2f3dd61

Please sign in to comment.