Don't use javascript in webelem.set_text for hints

This commit is contained in:
Florian Bruhin 2016-07-27 16:45:44 +02:00
parent 193c755637
commit 4318604c57
2 changed files with 8 additions and 4 deletions

View File

@ -1452,7 +1452,7 @@ class CommandDispatcher:
text: The new text to insert.
"""
try:
elem.set_text(text)
elem.set_text(text, use_js=True)
except webelem.IsNullError:
raise cmdexc.CommandError("Element vanished while editing!")

View File

@ -168,10 +168,14 @@ class WebElementWrapper(collections.abc.MutableMapping):
self._check_vanished()
return self._elem.styleProperty(name, strategy)
def set_text(self, text):
"""Set the given plain text."""
def set_text(self, text, *, use_js=False):
"""Set the given plain text.
Args:
use_js: Whether to use javascript if the element isn't content-editable.
"""
self._check_vanished()
if self.is_content_editable():
if self.is_content_editable() or not use_js:
log.misc.debug("Filling element {} via set_text.".format(
self.debug_text()))
self._elem.setPlainText(text)