Skip to content
This repository was archived by the owner on Apr 20, 2021. It is now read-only.

Commit f359c04

Browse files
Fix HttpCallListener when Mink driver is not started yet
1 parent 78b29a4 commit f359c04

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ matrix:
4444
before_script:
4545
- Xvfb $DISPLAY -extension RANDR &> /dev/null &
4646

47-
- LATEST_CHROMEDRIVER_VERSION=`curl http://chromedriver.storage.googleapis.com/LATEST_RELEASE`
48-
- wget --no-verbose https://chromedriver.storage.googleapis.com/$LATEST_CHROMEDRIVER_VERSION/chromedriver_linux64.zip
47+
- CHROME_MAIN_VERSION=`google-chrome-stable --version | sed -E 's/(^Google Chrome |\.[0-9]+ )//g'`
48+
- CHROMEDRIVER_VERSION=`curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_MAIN_VERSION"`
49+
- wget --no-verbose "https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip"
4950
- unzip chromedriver_linux64.zip -d ~/bin
5051

5152
- wget "https://selenium-release.storage.googleapis.com/${SELENIUM_VERSION%%.[[:digit:]]}/selenium-server-standalone-${SELENIUM_VERSION}.jar" -O selenium.jar

src/Context/BrowserContext.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ public function __construct($timeout = 1)
2525
*/
2626
public function closeBrowser()
2727
{
28-
$this->getSession()->stop();
28+
if ($this->getMink()->isSessionStarted()) {
29+
$this->getSession()->stop();
30+
}
2931
}
3032

3133
/**

src/HttpCall/HttpCallListener.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ public function afterStep(AfterStepTested $event)
5151
// For now to avoid modification on MinkContext
5252
// We add fallback on Mink
5353
try {
54-
$this->httpCallResultPool->store(
55-
new HttpCallResult($this->mink->getSession()->getPage()->getContent())
56-
);
54+
if ($this->mink->getSession()->isStarted()) {
55+
$this->httpCallResultPool->store(
56+
new HttpCallResult($this->mink->getSession()->getPage()->getContent())
57+
);
58+
}
5759
} catch (\LogicException $e) {
5860
// Mink has no response
5961
} catch (\Behat\Mink\Exception\DriverException $e) {

tests/features/browser.feature

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
Feature: Browser Feature
22

3+
@javascript
4+
Scenario: Testing when scenario has no HTTP call
5+
Given I wait 0.1 seconds
6+
37
# If this scenario fails
48
# It's probably because your web environment is not properly setup
5-
# You will find the necessery help in README.md
9+
# You will find the necessary help in README.md
610
@javascript
711
Scenario: Testing simple web access
812
Given I am on "/index.html"

0 commit comments

Comments
 (0)