Completed
Push — develop ( 723ec8...69e22a )
by Peter
08:18
created

WindowTrait::focusWindow()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 6
rs 9.4285
1
<?php
2
/**
3
 * Webino (http://webino.sk/)
4
 *
5
 * @link        https://github.com/webino/WebinoDev/ for the canonical source repository
6
 * @copyright   Copyright (c) 2018 Webino, s. r. o. (http://webino.sk/)
7
 * @license     BSD-3-Clause
8
 */
9
10
namespace WebinoDev\Test\Selenium;
11
12
/**
13
 * Trait WindowTrait
14
 *
15
 * @property-read object $session
16
 */
17
trait WindowTrait
18
{
19
    /**
20
     * Focus a browser window
21
     *
22
     * @param int $index
23
     * @return $this
24
     */
25
    protected function focusWindow($index)
26
    {
27
        $windows = $this->session->window_handles();
28
        $this->session->focusWindow($windows[$index]);
29
        return $this;
30
    }
31
32
    /**
33
     * Close a browser window
34
     *
35
     * @return $this
36
     */
37
    protected function closeWindow()
38
    {
39
        $this->session->deleteWindow();
40
        $this->focusWindow(0);
41
        return $this;
42
    }
43
}
44