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

Method wait_for

seleniumbase/undetected/cdp_driver/tab.py:1073–1112  ·  view source on GitHub ↗

Variant on query_selector_all and find_elements_by_text. This variant takes either selector or text, and will block until the requested element(s) are found. It will block for a maximum of seconds, after which a TimeoutError will be raised.

(
        self,
        selector: Optional[str] = "",
        text: Optional[str] = "",
        timeout: Optional[Union[int, float]] = 10,
    )

Source from the content-addressed store, hash-verified

1071 )
1072
1073 async def wait_for(
1074 self,
1075 selector: Optional[str] = "",
1076 text: Optional[str] = "",
1077 timeout: Optional[Union[int, float]] = 10,
1078 ) -> element.Element:
1079 """
1080 Variant on query_selector_all and find_elements_by_text.
1081 This variant takes either selector or text,
1082 and will block until the requested element(s) are found.
1083 It will block for a maximum of <timeout> seconds,
1084 after which a TimeoutError will be raised.
1085 :param selector: css selector
1086 :param text: text
1087 :param timeout:
1088 :return: Element
1089 :raises: asyncio.TimeoutError
1090 """
1091 loop = asyncio.get_running_loop()
1092 now = loop.time()
1093 if selector:
1094 item = await self.query_selector(selector)
1095 while not item:
1096 item = await self.query_selector(selector)
1097 if loop.time() - now > timeout:
1098 raise asyncio.TimeoutError(
1099 "Time ran out while waiting for: {%s}" % selector
1100 )
1101 await self.sleep(0.068)
1102 return item
1103 if text:
1104 item = await self.find_element_by_text(text)
1105 while not item:
1106 item = await self.find_element_by_text(text)
1107 if loop.time() - now > timeout:
1108 raise asyncio.TimeoutError(
1109 "Time ran out while waiting for: {%s}" % text
1110 )
1111 await self.sleep(0.068)
1112 return item
1113
1114 async def set_attributes(self, selector, attribute, value):
1115 """This method uses JavaScript to set/update a common attribute.

Callers 7

selectMethod · 0.95
__call__Method · 0.95
getMethod · 0.80
__init__Method · 0.80
waitMethod · 0.80
listener_loopMethod · 0.80

Calls 3

query_selectorMethod · 0.95
find_element_by_textMethod · 0.95
sleepMethod · 0.45

Tested by

no test coverage detected