Prose\UsingBrowser::switchToWindow PHP Method

switchToWindow() public method

public switchToWindow ( $name )
    public function switchToWindow($name)
    {
        // shorthand
        $browser = $this->device;
        // what are we doing?
        $log = usingLog()->startAction("switch to browser window called '{$name}'");
        // get the list of available window handles
        $handles = $browser->window_handles();
        // we have to iterate over them, to find the window that we want
        foreach ($handles as $handle) {
            // switch to the window
            $browser->focusWindow($handle);
            // is this the window that we want?
            $title = $browser->title();
            if ($title == $name) {
                // all done
                $log->endAction();
                return;
            }
        }
        // if we get here, then we could not find the window we wanted
        // the browser might be pointing at ANY of the open windows,
        // and it might be pointing at no window at all
        throw new E5xx_ActionFailed(__METHOD__, "No such window '{$name}'");
    }