def wait_for_visibility(
driver: webdriver, *, by_css: str = None,
by_id: str = None, time_to_wait: int = 5):
"""Wait until element is visible.
:param driver: Selenium driver
:param by_css: CSS selector to locate the element to wait for
:param by_id: ID of the element to wait for
:param time_to_wait: maximum number of seconds to wait
"""
assert by_id or by_css, "Provide ID or CSS selector"
if by_css:
by_locator = (By.CSS_SELECTOR, by_css)
else:
by_locator = (By.ID, by_id)
WebDriverWait(driver, time_to_wait).until(
expected_conditions.visibility_of_element_located(by_locator))
评论列表
文章目录