I'm a fan of behavior testing using Splinter which bases on Selenium. The problem with a FroalaField in those tests is, that they are not rendered as form fields and so they can not get filled by the default Selenium/Splinter methods. So I would like to be able do deactivate the FroalaEditor when running those tests using settings.py.
As a proof of concept I implemented this as follows:
from django.conf import settings
from froala_editor.fields import FroalaField
from django.forms.widgets import Textarea
class DeactivatableFroalaField(FroalaField):
"""
FroalaField which allows to disable the FroalaEditor widget
using settings.py's variable USE_FROALA_EDITOR
"""
def formfield(self, **kwargs):
try:
use_froala_editor = settings.USE_FROALA_EDITOR
except AttributeError:
use_froala_editor = True
if use_froala_editor is False:
# disable the Froala Editor by just
# rendering a Textarea
defaults = {
'widget': Textarea()
}
defaults.update(kwargs)
return super(DeactivatableFroalaField, self).formfield(**defaults)
else:
# leave as it is
return super(DeactivatableFroalaField, self).formfield(**kwargs)
As this is quite useful for me, I kindly ask the developers to "incorporate" this idea into the code base.
I'm a fan of behavior testing using Splinter which bases on Selenium. The problem with a
FroalaField
in those tests is, that they are not rendered as form fields and so they can not get filled by the default Selenium/Splinter methods. So I would like to be able do deactivate the FroalaEditor when running those tests usingsettings.py
.As a proof of concept I implemented this as follows:
As this is quite useful for me, I kindly ask the developers to "incorporate" this idea into the code base.