Add a focus_elem function to utils.webelem.
This commit is contained in:
parent
bbd9d24334
commit
810e507da9
@ -711,8 +711,7 @@ class CommandDispatcher:
|
|||||||
and do everything async.
|
and do everything async.
|
||||||
"""
|
"""
|
||||||
frame = self._tabs.currentWidget().page().currentFrame()
|
frame = self._tabs.currentWidget().page().currentFrame()
|
||||||
elem = frame.findFirstElement(webelem.SELECTORS[
|
elem = webelem.focus_elem(frame)
|
||||||
webelem.Group.focus])
|
|
||||||
if elem.isNull():
|
if elem.isNull():
|
||||||
raise CommandError("No element focused!")
|
raise CommandError("No element focused!")
|
||||||
if not webelem.is_editable(elem):
|
if not webelem.is_editable(elem):
|
||||||
|
@ -247,3 +247,14 @@ def is_editable(elem):
|
|||||||
log.webview.debug("span with classes {} clicked!".format(
|
log.webview.debug("span with classes {} clicked!".format(
|
||||||
elem.classes()))
|
elem.classes()))
|
||||||
return False
|
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])
|
||||||
|
Loading…
Reference in New Issue
Block a user