Chris@0: browser->windowName(); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Return all the window handles currently present in phantomjs Chris@0: * @return array Chris@0: */ Chris@0: public function getWindowNames() { Chris@0: return $this->browser->windowHandles(); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Switches to window by name if possible Chris@0: * @param $name Chris@0: * @throws DriverException Chris@0: */ Chris@0: public function switchToWindow($name = null) { Chris@0: $handles = $this->browser->windowHandles(); Chris@0: if ($name === null) { Chris@0: //null means back to the main window Chris@0: return $this->browser->switchToWindow($handles[0]); Chris@0: } Chris@0: Chris@0: $windowHandle = $this->browser->windowHandle($name); Chris@0: if (!empty($windowHandle)) { Chris@0: $this->browser->switchToWindow($windowHandle); Chris@0: } else { Chris@0: throw new DriverException("Could not find window handle by a given window name: $name"); Chris@0: } Chris@0: Chris@0: } Chris@0: Chris@0: /** Chris@0: * Resizing a window with specified size Chris@0: * @param int $width Chris@0: * @param int $height Chris@0: * @param string $name Chris@0: * @throws DriverException Chris@0: */ Chris@0: public function resizeWindow($width, $height, $name = null) { Chris@0: if ($name !== null) { Chris@0: //TODO: add this on the phantomjs stuff Chris@0: throw new DriverException("Resizing other window than the main one is not supported yet"); Chris@0: } Chris@0: $this->browser->resize($width, $height); Chris@0: } Chris@0: Chris@0: }