def switch_to_frame(self, frame):
if isinstance(frame, Element):<EOL><INDENT>self.driver.switch_to_frame(frame)<EOL>self._scopes.append("<STR_LIT>")<EOL><DEDENT>elif frame == "<STR_LIT>":<EOL><INDENT>if self._scopes[-<NUM_LIT:1>] != "<STR_LIT>":<EOL><INDENT>raise ScopeError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>self._scopes.pop()<EOL>self.driver.switch_to_frame("<STR_LIT>")<EOL><DEDENT>elif frame == "<STR_LIT>":<EOL><INDENT>if "<STR_LIT>" in self._scopes:<EOL><INDENT>idx = self._scopes.index("<STR_LIT>")<EOL>if any([scope not in ["<STR_LIT>", None] for scope in self._scopes[idx:]]):<EOL><INDENT>raise ScopeError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>self._scopes = self._scopes[:idx]<EOL>self.driver.switch_to_frame("<STR_LIT>")<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>
Switch to the given frame.

If you use this method you are responsible for making sure you switch back to the parent
frame when done in the frame changed to. :meth:`frame` is preferred over this method and
should be used when possible. May not be supported by all drivers.

Args:
    frame (Element | str): The iframe/frame element to switch to.