Add tab.elem.find_id
This commit is contained in:
parent
afc7faabda
commit
5ac9fe9c32
@ -433,6 +433,15 @@ class AbstractElements:
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def find_id(self, elem_id, callback):
|
||||||
|
"""Find the HTML element with the given ID async.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
callback: The callback to be called when the search finished.
|
||||||
|
elem_id: The ID to search for.
|
||||||
|
"""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
def find_focused(self, callback):
|
def find_focused(self, callback):
|
||||||
"""Find the focused element on the page async.
|
"""Find the focused element on the page async.
|
||||||
|
|
||||||
|
@ -351,6 +351,11 @@ class WebEngineElements(browsertab.AbstractElements):
|
|||||||
js_cb = functools.partial(self._js_cb_multiple, callback)
|
js_cb = functools.partial(self._js_cb_multiple, callback)
|
||||||
self._tab.run_js_async(js_code, js_cb)
|
self._tab.run_js_async(js_code, js_cb)
|
||||||
|
|
||||||
|
def find_id(self, elem_id, callback):
|
||||||
|
js_code = javascript.assemble('document', 'getElementById', elem_id)
|
||||||
|
js_cb = functools.partial(self._js_cb_single, callback)
|
||||||
|
self._tab.run_js_async(js_code, js_cb)
|
||||||
|
|
||||||
def find_focused(self, callback):
|
def find_focused(self, callback):
|
||||||
js_code = javascript.assemble('webelem', 'focus_element')
|
js_code = javascript.assemble('webelem', 'focus_element')
|
||||||
js_cb = functools.partial(self._js_cb_single, callback)
|
js_cb = functools.partial(self._js_cb_single, callback)
|
||||||
|
@ -512,6 +512,9 @@ class WebKitElements(browsertab.AbstractElements):
|
|||||||
|
|
||||||
callback(elems)
|
callback(elems)
|
||||||
|
|
||||||
|
def find_id(self, elem_id, callback):
|
||||||
|
self.find_css('#' + elem_id, callback)
|
||||||
|
|
||||||
def find_focused(self, callback):
|
def find_focused(self, callback):
|
||||||
frame = self._widget.page().currentFrame()
|
frame = self._widget.page().currentFrame()
|
||||||
if frame is None:
|
if frame is None:
|
||||||
|
Loading…
Reference in New Issue
Block a user