def wait_for_element_visible(driver, selector, by=By.CSS_SELECTOR,<EOL>timeout=settings.LARGE_TIMEOUT):
element = None<EOL>start_ms = time.time() * <NUM_LIT><EOL>stop_ms = start_ms + (timeout * <NUM_LIT>)<EOL>for x in range(int(timeout * <NUM_LIT:10>)):<EOL><INDENT>try:<EOL><INDENT>element = driver.find_element(by=by, value=selector)<EOL>if element.is_displayed():<EOL><INDENT>return element<EOL><DEDENT>else:<EOL><INDENT>element = None<EOL>raise Exception()<EOL><DEDENT><DEDENT>except Exception:<EOL><INDENT>now_ms = time.time() * <NUM_LIT><EOL>if now_ms >= stop_ms:<EOL><INDENT>break<EOL><DEDENT>time.sleep(<NUM_LIT:0.1>)<EOL><DEDENT><DEDENT>plural = "<STR_LIT:s>"<EOL>if timeout == <NUM_LIT:1>:<EOL><INDENT>plural = "<STR_LIT>"<EOL><DEDENT>if not element and by != By.LINK_TEXT:<EOL><INDENT>raise ElementNotVisibleException(<EOL>"<STR_LIT>" % (<EOL>selector, timeout, plural))<EOL><DEDENT>if not element and by == By.LINK_TEXT:<EOL><INDENT>raise ElementNotVisibleException(<EOL>"<STR_LIT>" % (<EOL>selector, timeout, plural))<EOL><DEDENT>
Searches for the specified element by the given selector. Returns the
element object if the element is present and visible on the page.
Raises an exception if the element does not appear in the
specified timeout.
@Params
driver - the webdriver object (required)
selector - the locator that is used (required)
by - the method to search for the locator (Default: By.CSS_SELECTOR)
timeout - the time to wait for elements in seconds

@Returns
A web element object