browser.wait#
Functions#
for_element(xpath, timeout=None)
#
Wait until element is ready in the DOM and/or on the screen.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xpath | str | XPath of the element. | required |
timeout | float | None | In seconds. Timeout to wait for element. If | None |
Example
Useful for single-page app elements handled by JavaScript, but also standard HTML that doesn't load immediately. This helper function ensures that DOM elements are ready before processing. The example waits for any H1 headline to be ready:
random_seconds(min_seconds=1, max_seconds=5)
#
Sleep for a random amount of time to make actions look less like a bot. The waiting time will be somewhere between the speficied minimum and maximum seconds.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
min_seconds | float | Minimum seconds to wait. | 1 |
max_seconds | float | Maximum seconds to wait. | 5 |