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

Commit

Permalink
Fix HttpCallListener when Mink driver is not started yet
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamin-vauchel-webrivage committed Oct 9, 2020
1 parent 78b29a4 commit b00cce0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ matrix:
before_script:
- Xvfb $DISPLAY -extension RANDR &> /dev/null &

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

- wget "https://selenium-release.storage.googleapis.com/${SELENIUM_VERSION%%.[[:digit:]]}/selenium-server-standalone-${SELENIUM_VERSION}.jar" -O selenium.jar
Expand Down
4 changes: 3 additions & 1 deletion src/Context/BrowserContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ public function __construct($timeout = 1)
*/
public function closeBrowser()
{
$this->getSession()->stop();
if ($this->getMink()->isSessionStarted()) {
$this->getSession()->stop();
}
}

/**
Expand Down
8 changes: 5 additions & 3 deletions src/HttpCall/HttpCallListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ public function afterStep(AfterStepTested $event)
// For now to avoid modification on MinkContext
// We add fallback on Mink
try {
$this->httpCallResultPool->store(
new HttpCallResult($this->mink->getSession()->getPage()->getContent())
);
if ($this->mink->getSession()->isStarted()) {
$this->httpCallResultPool->store(
new HttpCallResult($this->mink->getSession()->getPage()->getContent())
);
}
} catch (\LogicException $e) {
// Mink has no response
} catch (\Behat\Mink\Exception\DriverException $e) {
Expand Down
6 changes: 5 additions & 1 deletion tests/features/browser.feature
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
Feature: Browser Feature

@javascript
Scenario: Testing when scenario has no HTTP call
Given I wait 0.1 seconds

# If this scenario fails
# It's probably because your web environment is not properly setup
# You will find the necessery help in README.md
# You will find the necessary help in README.md
@javascript
Scenario: Testing simple web access
Given I am on "/index.html"
Expand Down

0 comments on commit b00cce0

Please sign in to comment.