1<?php
2
3namespace Facebook\WebDriver;
4
5/**
6 * Used to locate a given frame or window.
7 */
8interface WebDriverTargetLocator
9{
10    /** @var string */
11    const WINDOW_TYPE_WINDOW = 'window';
12    /** @var string */
13    const WINDOW_TYPE_TAB = 'tab';
14
15    /**
16     * Set the current browsing context to the current top-level browsing context.
17     * This is the same as calling `RemoteTargetLocator::frame(null);`
18     *
19     * @return WebDriver The driver focused on the top window or the first frame.
20     */
21    public function defaultContent();
22
23    /**
24     * Switch to the iframe by its id or name.
25     *
26     * @param WebDriverElement|null|int|string $frame The WebDriverElement, the id or the name of the frame.
27     * When null, switch to the current top-level browsing context When int, switch to the WindowProxy identified
28     * by the value. When an Element, switch to that Element.
29     *
30     * @throws \InvalidArgumentException
31     * @return WebDriver The driver focused on the given frame.
32     */
33    public function frame($frame);
34
35    // TODO: Add in next major release (BC)
36    ///**
37    // * Switch to the parent iframe.
38    // *
39    // * @return WebDriver This driver focused on the parent frame
40    // */
41    //public function parent();
42
43    /**
44     * Switch the focus to another window by its handle.
45     *
46     * @param string $handle The handle of the window to be focused on.
47     * @return WebDriver The driver focused on the given window.
48     * @see WebDriver::getWindowHandles
49     */
50    public function window($handle);
51
52    // TODO: Add in next major release (BC)
53    //public function newWindow($windowType = self::WINDOW_TYPE_TAB);
54
55    /**
56     * Switch to the currently active modal dialog for this particular driver instance.
57     *
58     * @return WebDriverAlert
59     */
60    public function alert();
61
62    /**
63     * Switches to the element that currently has focus within the document currently "switched to",
64     * or the body element if this cannot be detected.
65     *
66     * @return WebDriverElement
67     */
68    public function activeElement();
69}
70