diff --git a/lib/WebDriverTargetLocator.php b/lib/WebDriverTargetLocator.php
index <HASH>..<HASH> 100644
--- a/lib/WebDriverTargetLocator.php
+++ b/lib/WebDriverTargetLocator.php
@@ -41,10 +41,18 @@ class WebDriverTargetLocator {
   /**
    * Switch to the iframe by its id or name.
    *
+   * @param WebDriverElement|string $frame The WebDriverElement,
+                                           the id or the name of the frame.
    * @return WebDriver The driver focused on the given frame.
    */
-  public function frame($id_or_name) {
-    $params = array('id' => (string)$id_or_name);
+  public function frame($frame) {
+    if ($frame instanceof WebDriverElement) {
+      $id = array('ELEMENT' => $frame->getID());
+    } else {
+      $id = (string)$frame;
+    }
+
+    $params = array('id' => $id);
     $this->executor->execute('focusFrame', $params);
 
     return $this->driver;
[switchTo] switch to frame by WebDriverElement

Allow switching to a frame by the WebDriverElement.

Sample:
$frame_element = $driver->findElement($by);
$driver->switchTo()->frame($frame_element);