def METHOD_NAME(self, window_name: str) -> None:
    def send_handle(h):
        self._driver.execute(Command.SWITCH_TO_WINDOW, {"handle": h})
    try:
        # Try using it as a handle first.
        send_handle(window_name)
    except NoSuchWindowException:
        # Check every window to try to find the given window name.
        original_handle = self._driver.current_window_handle
        handles = self._driver.window_handles
        for handle in handles:
            send_handle(handle)
            current_name = self._driver.execute_script("return window.name")
            if window_name == current_name:
                return
        send_handle(original_handle)
        raise