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

WindowTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 27
rs 10
wmc 2
lcom 1
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A focusWindow() 0 6 1
A closeWindow() 0 6 1
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