1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace BeubiQA\Application\Selenium; |
4
|
|
|
|
5
|
|
|
use BeubiQA\Application\Lib\LogWatcher; |
6
|
|
|
use BeubiQA\Application\Selenium; |
7
|
|
|
|
8
|
|
|
class SeleniumHandler |
9
|
|
|
{ |
10
|
|
|
/** @var Selenium\SeleniumStarter */ |
11
|
|
|
protected $seleniumStarter; |
12
|
|
|
/** @var Selenium\SeleniumStopper */ |
13
|
|
|
protected $seleniumStopper; |
14
|
|
|
/** @var Selenium\SeleniumDownloader */ |
15
|
|
|
protected $seleniumDownloader; |
16
|
|
|
/** @var LogWatcher */ |
17
|
|
|
protected $seleniumLogWatcher; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @param Selenium\SeleniumStarter $seleniumStarter |
21
|
|
|
* @param Selenium\SeleniumStopper $seleniumStopper |
22
|
|
|
* @param Selenium\SeleniumDownloader $seleniumDownloader |
23
|
|
|
* @param LogWatcher $seleniumLogWatcher |
24
|
|
|
*/ |
25
|
|
|
public function __construct( |
26
|
|
|
Selenium\SeleniumStarter $seleniumStarter, |
27
|
|
|
Selenium\SeleniumStopper $seleniumStopper, |
28
|
|
|
Selenium\SeleniumDownloader $seleniumDownloader, |
29
|
|
|
LogWatcher $seleniumLogWatcher |
30
|
|
|
) { |
31
|
|
|
$this->seleniumStarter = $seleniumStarter; |
32
|
|
|
$this->seleniumStopper = $seleniumStopper; |
33
|
|
|
$this->seleniumDownloader = $seleniumDownloader; |
34
|
|
|
$this->seleniumLogWatcher = $seleniumLogWatcher; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @return Selenium\SeleniumStarter |
39
|
|
|
*/ |
40
|
|
|
public function getStarter() |
41
|
|
|
{ |
42
|
|
|
return $this->seleniumStarter; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @return Selenium\SeleniumStopper |
47
|
|
|
*/ |
48
|
|
|
public function getStopper() |
49
|
|
|
{ |
50
|
|
|
return $this->seleniumStopper; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @return Selenium\SeleniumDownloader |
55
|
|
|
*/ |
56
|
|
|
public function getDownloader() |
57
|
|
|
{ |
58
|
|
|
return $this->seleniumDownloader; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function start() |
62
|
|
|
{ |
63
|
|
|
if (!$this->getDownloader()->isJarAlreadyDownloaded()) { |
64
|
|
|
$this->download(); |
65
|
|
|
} |
66
|
|
|
if (!$this->getStarter()->isSeleniumAvailable()) { |
67
|
|
|
$this->seleniumStarter->start(); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function stop() |
72
|
|
|
{ |
73
|
|
|
$this->seleniumStopper->stop(); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function download() |
77
|
|
|
{ |
78
|
|
|
$this->seleniumDownloader->download(); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function watch() |
82
|
|
|
{ |
83
|
|
|
$this->seleniumLogWatcher->watch(); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|