diff --git a/src/Selenium2Driver.php b/src/Selenium2Driver.php index ee7f2e75..af083a67 100755 --- a/src/Selenium2Driver.php +++ b/src/Selenium2Driver.php @@ -415,7 +415,12 @@ public function back() */ public function switchToWindow($name = null) { - $this->wdSession->focusWindow($name ?: ''); + if ($name === null) { + $handles = $this->wdSession->window_handles(); + $name = reset($handles); + } + + $this->wdSession->focusWindow($name); } /**