forked from sttas/SeleniumTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathActorBrowserController.php
69 lines (60 loc) · 1.43 KB
/
ActorBrowserController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
namespace Modera\Component\SeleniumTools;
/**
* @internal
*
* @author Sergei Lissovski <[email protected]>
* @copyright 2017 Modera Foundation
*/
class ActorBrowserController
{
/**
* @var Actor
*/
private $actor;
/**
* @param Actor $actor
*/
public function __construct(Actor $actor)
{
$this->actor = $actor;
}
/**
* @return bool
*/
public function doesBrowserNeedToBeLaunchedAutomatically()
{
return $this->actor->isBehaviourEnabled(Actor::BHR_AUTO_START);
}
/**
* @param string $url
*/
public function launchBrowser($url)
{
$this->actor->getDriver()->get($url);
}
/**
* @return bool
*/
public function doesBrowserWindowNeedToBeMaximized()
{
return $this->actor->isBehaviourEnabled(Actor::BHR_AUTO_MAXIMIZE);
}
public function maximizeBrowser()
{
$this->actor->getDriver()->manage()->window()->maximize();
// it takes about a second for a browser to be maximized and its UI properly redrawn
sleep(1);
}
/**
* @return bool
*/
public function isFocusingNeeded()
{
return $this->actor->isBehaviourEnabled(Actor::BHR_AUTO_FOCUS) && $this->isExcessiveFocusingAvoided();
}
private function isExcessiveFocusingAvoided()
{
return !$this->actor->getHarness()->isActorActive($this->actor);
}
}