1: <?php
2: namespace Peridot\WebDriverManager\Binary;
3:
4: use Peridot\WebDriverManager\Versions;
5:
6: /**
7: * IEDriver is used to resolve the Selenium Server driver for using the Internet Explorer
8: * web browser.
9: *
10: * @package Peridot\WebDriverManager\Binary
11: */
12: class IEDriver extends CompressedBinary implements DriverInterface
13: {
14: /**
15: * {@inheritdoc}
16: *
17: * @return string
18: */
19: public function getName()
20: {
21: return 'IEDriver';
22: }
23:
24: /**
25: * {@inheritdoc}
26: *
27: * @return string
28: */
29: public function getFileName()
30: {
31: if ($this->isSupported()) {
32: $file = "IEDriverServer_Win32_";
33:
34: if ($this->resolver->getSystem()->is64Bit()) {
35: $file = 'IEDriverServer_x64_';
36: }
37:
38: return $file . Versions::IEDRIVER . '.zip';
39: }
40: return "";
41: }
42:
43: /**
44: * {@inheritdoc}
45: *
46: * @return string
47: */
48: public function getUrl()
49: {
50: $fileName = $this->getFileName();
51:
52: if (!$fileName) {
53: return '';
54: }
55:
56: $version = Versions::IEDRIVER;
57: $short = substr($version, 0, strrpos($version, '.'));
58: return "http://selenium-release.storage.googleapis.com/$short/{$this->getFileName()}";
59: }
60:
61: /**
62: * {@inheritdoc}
63: *
64: * @return string
65: */
66: public function getOutputFileName()
67: {
68: $version = Versions::IEDRIVER;
69: return "IEDriver_$version.zip";
70: }
71:
72: /**
73: * {@inheritdoc}
74: *
75: * @return bool
76: */
77: public function isSupported()
78: {
79: $system = $this->resolver->getSystem();
80: return $system->isWindows();
81: }
82:
83: /**
84: * Remove old versions of the binary.
85: *
86: * @param $directory
87: * @return void
88: */
89: protected function removeOldVersions($directory)
90: {
91: $paths = glob("$directory/IEDriver*");
92: foreach ($paths as $path) {
93: unlink($path);
94: }
95: }
96:
97: /**
98: * {@inheritdoc}
99: *
100: * @param string $directory
101: * @return string
102: */
103: protected function getOldFilePattern($directory)
104: {
105: return $directory . '/' . str_replace(Versions::IEDRIVER, '*', $this->getOutputFileName());
106: }
107:
108: /**
109: * {@inheritdoc}
110: *
111: * @param string $directory
112: * @return string
113: */
114: public function getDriverPath($directory)
115: {
116: $file = "$directory/{$this->getExtractedName()}";
117: return "webdriver.ie.driver=$file";
118: }
119:
120: /**
121: * {@inheritdoc}
122: *
123: * @return string
124: */
125: public function getExtractedName()
126: {
127: return 'IEDriverServer.exe';
128: }
129: }
130: