MCPcopy Create free account
hub / github.com/seleniumbase/SeleniumBase / update

Method update

seleniumbase/undetected/cdp_driver/element.py:244–286  ·  view source on GitHub ↗

Updates element to retrieve more properties. For example this enables: :py:obj:`~children` and :py:obj:`~parent` attributes. Also resolves js object, which is a stored object in :py:obj:`~remote_object`. Usually you will get element nodes by the

(self, _node=None)

Source from the content-addressed store, hash-verified

242 # self._tree = util.remove_from_tree(self.tree, self.node)
243
244 async def update(self, _node=None):
245 """
246 Updates element to retrieve more properties.
247 For example this enables:
248 :py:obj:`~children` and :py:obj:`~parent` attributes.
249 Also resolves js object,
250 which is a stored object in :py:obj:`~remote_object`.
251 Usually you will get element nodes by the usage of:
252 :py:meth:`Tab.query_selector_all()`
253 :py:meth:`Tab.find_elements_by_text()`
254 Those elements are already updated and you can browse
255 through children directly.
256 """
257 if _node:
258 doc = _node
259 # self._node = _node
260 # self._children.clear()
261 self._parent = None
262 else:
263 doc = await self._tab.send(cdp.dom.get_document(-1, True))
264 self._parent = None
265 # if self.node_name != "IFRAME":
266 updated_node = util.filter_recurse(
267 doc, lambda n: n.backend_node_id == self._node.backend_node_id
268 )
269 if updated_node:
270 logger.debug("Node changed, and has now been updated.")
271 self._node = updated_node
272 self._tree = doc
273 self._remote_object = await self._tab.send(
274 cdp.dom.resolve_node(backend_node_id=self._node.backend_node_id)
275 )
276 # self.attrs.clear()
277 self._make_attrs()
278 if self.node_name != "IFRAME":
279 parent_node = util.filter_recurse(
280 doc, lambda n: n.node_id == self.node.parent_id
281 )
282 if not parent_node:
283 # Could happen if node is for example <html>
284 return self
285 self._parent = create(parent_node, tab=self._tab, tree=self._tree)
286 return self
287
288 @property
289 def node(self):

Callers 15

save_to_dom_asyncMethod · 0.95
remove_from_dom_asyncMethod · 0.95
__await__Method · 0.95
set_text_asyncMethod · 0.95
query_selector_asyncMethod · 0.95
create_tkinter_guiFunction · 0.80
create_tkinter_guiFunction · 0.80
create_tkinter_guiFunction · 0.80
create_tkinter_guiFunction · 0.80
from_optionsMethod · 0.80
find_chrome_executableFunction · 0.80

Calls 4

_make_attrsMethod · 0.95
createFunction · 0.85
sendMethod · 0.45
get_documentMethod · 0.45

Tested by

no test coverage detected