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

Method is_element_visible

seleniumbase/undetected/cdp_driver/tab.py:1350–1374  ·  view source on GitHub ↗
(self, selector)

Source from the content-addressed store, hash-verified

1348 return False
1349
1350 async def is_element_visible(self, selector):
1351 if ":contains(" not in selector:
1352 try:
1353 element = await self.select(selector, timeout=0.01)
1354 except Exception:
1355 return False
1356 if not element:
1357 return False
1358 try:
1359 position = await element.get_position_async()
1360 return (position.width != 0 or position.height != 0)
1361 except Exception:
1362 return False
1363 else:
1364 with suppress(Exception):
1365 tag_name = selector.split(":contains(")[0].split(" ")[-1]
1366 text = selector.split(":contains(")[1].split(")")[0][1:-1]
1367 element = await self.select(tag_name, timeout=0.01)
1368 if not element:
1369 raise Exception()
1370 element = await self.find_element_by_text(text)
1371 if not element:
1372 raise Exception()
1373 return True
1374 return False
1375
1376 async def __on_a_cf_turnstile_page(self, source=None):
1377 if not source or len(source) < 400:

Calls 3

selectMethod · 0.95
find_element_by_textMethod · 0.95
get_position_asyncMethod · 0.80

Tested by

no test coverage detected