Get rid of webelem.run_js_async

This commit is contained in:
Florian Bruhin 2016-09-07 11:27:37 +02:00
parent 78d64f4791
commit 8f9cfcf232
4 changed files with 2 additions and 28 deletions

View File

@ -162,11 +162,6 @@ class AbstractWebElement(collections.abc.MutableMapping):
"""Insert the given text into the element."""
raise NotImplementedError
def run_js_async(self, code, callback=None):
"""Run the given JS snippet async on the element."""
# FIXME:qtwebengine get rid of this?
raise NotImplementedError
def parent(self):
"""Get the parent element of this element."""
# FIXME:qtwebengine get rid of this?

View File

@ -115,11 +115,6 @@ class WebEngineElement(webelem.AbstractWebElement):
js_code = javascript.assemble('webelem', 'insert_text', self._id, text)
self._tab.run_js_async(js_code)
def run_js_async(self, code, callback=None):
"""Run the given JS snippet async on the element."""
# FIXME:qtwebengine get rid of this?
log.stub()
def parent(self):
"""Get the parent element of this element."""
# FIXME:qtwebengine get rid of this?

View File

@ -139,20 +139,13 @@ class WebKitElement(webelem.AbstractWebElement):
if not self.is_editable(strict=True):
raise webelem.Error("Element is not editable!")
log.misc.debug("Inserting text into element {!r}".format(self))
self.run_js_async("""
self._elem.evaluateJavaScript("""
var text = '{}';
var event = document.createEvent('TextEvent');
event.initTextEvent('textInput', true, true, null, text);
this.dispatchEvent(event);
""".format(javascript.string_escape(text)))
def run_js_async(self, code, callback=None):
"""Run the given JS snippet async on the element."""
self._check_vanished()
result = self._elem.evaluateJavaScript(code)
if callback is not None:
callback(result)
def parent(self):
self._check_vanished()
elem = self._elem.parent()

View File

@ -268,14 +268,13 @@ class TestWebKitElement:
lambda e: e.debug_text(),
lambda e: e.outer_xml(),
lambda e: e.tag_name(),
lambda e: e.run_js_async(''),
lambda e: e.rect_on_view(),
lambda e: e.is_visible(None),
], ids=['str', 'getitem', 'setitem', 'delitem', 'contains', 'iter', 'len',
'frame', 'geometry', 'style_property', 'text', 'set_text',
'is_writable', 'is_content_editable', 'is_editable',
'is_text_input', 'remove_blank_target', 'debug_text', 'outer_xml',
'tag_name', 'run_js_async', 'rect_on_view', 'is_visible'])
'tag_name', 'rect_on_view', 'is_visible'])
def test_vanished(self, elem, code):
"""Make sure methods check if the element is vanished."""
elem._elem.isNull.return_value = True
@ -442,14 +441,6 @@ class TestWebKitElement:
called_mock = getattr(elem._elem, attr)
called_mock.assert_called_with(arg)
@pytest.mark.parametrize('with_cb', [True, False])
def test_run_js_async(self, elem, with_cb):
cb = mock.Mock(spec={}) if with_cb else None
elem._elem.evaluateJavaScript.return_value = 42
elem.run_js_async('the_answer();', cb)
if with_cb:
cb.assert_called_with(42)
class TestRemoveBlankTarget: