def switch_to_frame(driver, frame, timeout=settings.SMALL_TIMEOUT):
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>driver.switch_to.frame(frame)<EOL>return True<EOL><DEDENT>except NoSuchFrameException:<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>raise Exception("<STR_LIT>" % timeout)<EOL>
Wait for an iframe to appear, and switch to it. This should be usable
as a drop-in replacement for driver.switch_to.frame().
@Params
driver - the webdriver object (required)
frame - the frame element, name, or index
timeout - the time to wait for the alert in seconds