Add a focus_elem function to utils.webelem.

This commit is contained in:
Florian Bruhin 2014-07-16 07:55:30 +02:00
parent bbd9d24334
commit 810e507da9
2 changed files with 12 additions and 2 deletions

View File

@ -711,8 +711,7 @@ class CommandDispatcher:
and do everything async.
"""
frame = self._tabs.currentWidget().page().currentFrame()
elem = frame.findFirstElement(webelem.SELECTORS[
webelem.Group.focus])
elem = webelem.focus_elem(frame)
if elem.isNull():
raise CommandError("No element focused!")
if not webelem.is_editable(elem):

View File

@ -247,3 +247,14 @@ def is_editable(elem):
log.webview.debug("span with classes {} clicked!".format(
elem.classes()))
return False
def focus_elem(frame):
"""Get the focused element in a webframe.
FIXME: Add tests.
Args:
frame: The QWebFrame to search in.
"""
return frame.findFirstElement(SELECTORS[Group.focus])