Skip to content

Commit 5352c9a

Browse files
authored
Merge pull request #297 from stof/timeout
Improve the timeout handling
2 parents 60fb967 + 5944f58 commit 5352c9a

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

src/Selenium2Driver.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,15 +299,13 @@ public function start()
299299
{
300300
try {
301301
$this->wdSession = $this->webDriver->session($this->browserName, $this->desiredCapabilities);
302-
$this->applyTimeouts();
303302
} catch (\Exception $e) {
304303
throw new DriverException('Could not open connection: '.$e->getMessage(), 0, $e);
305304
}
306305

307-
if (!$this->wdSession) {
308-
throw new DriverException('Could not connect to a Selenium 2 / WebDriver server');
309-
}
310306
$this->started = true;
307+
308+
$this->applyTimeouts();
311309
}
312310

313311
/**

tests/Custom/TimeoutTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,24 @@ class TimeoutTest extends TestCase
99
{
1010
use ExpectException;
1111

12+
/**
13+
* @after
14+
*/
15+
protected function resetSessions()
16+
{
17+
$session = $this->getSession();
18+
19+
// Stop the session instead of only resetting it, as timeouts are not reset (they are configuring the session itself)
20+
if ($session->isStarted()) {
21+
$session->stop();
22+
}
23+
24+
// Reset the array of timeouts to avoid impacting other tests
25+
$session->getDriver()->setTimeouts(array());
26+
27+
parent::resetSessions();
28+
}
29+
1230
public function testInvalidTimeoutSettingThrowsException()
1331
{
1432
$this->expectException('\Behat\Mink\Exception\DriverException');

0 commit comments

Comments
 (0)