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

Fix HttpCallListener when Mink driver is not started yet #292

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: php

dist: trusty
dist: xenial

addons:
chrome: stable
Expand Down 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