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

Conversation

benjamin-vauchel-webrivage

Fix the following error when BehatchExtension is used with Selenium2 Mink driver :

[11-Sep-2020 12:14:21 Europe/Paris] PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function source() on null in /app/vendor/behat/mink-selenium2-driver/src/Selenium2Driver.php:487 Stack trace: #0 /app/vendor/behat/mink/src/Element/DocumentElement.php(37): Behat\Mink\Driver\Selenium2Driver->getContent() #1 /app/vendor/behatch/contexts/src/HttpCall/HttpCallListener.php(55): Behat\Mink\Element\DocumentElement->getContent() #2 /app/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php(184): Behatch\HttpCall\HttpCallListener->afterStep(Object(Behat\Behat\EventDispatcher\Event\AfterStepTested), 'tester.step_tes...', Object(Behat\Testwork\EventDispatcher\TestworkEventDispatcher)) #3 /app/vendor/behat/behat/src/Behat/Testwork/EventDispatcher/TestworkEventDispatcher.php(39): Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(Array, 'tester.step_tes...', Object(Behat\Behat\EventDispatcher\Event\AfterStepTested)) #4 /app/vendor/behat/behat/src/Behat/Behat/EventDispatcher/Tester/EventD in /app/vendor/behat/mink-selenium2-driver/src/Selenium2Driver.php on line 487

Behat\Mink\Driver\Selenium2Driver->getContent() is called whereas the driver hasn't started yet.

@benjamin-vauchel-webrivage
Copy link
Author

@sanpii Could you take a look to the PR please ? ;)

robertfausk added a commit to robertfausk/mink-panther-driver that referenced this pull request Oct 8, 2020
This resolves amongst other things issues with behatch
also see:
Behatch/contexts#284
Behatch/contexts#292
@robertfausk
Copy link

robertfausk commented Oct 8, 2020

This PR looks good to me 😃
@benjamin-vauchel-webrivage Could you provide a test case too?

@benjamin-vauchel-webrivage benjamin-vauchel-webrivage force-pushed the benjamin-vauchel-webrivage-patch-1 branch 5 times, most recently from b00cce0 to f359c04 Compare October 9, 2020 12:46
@robertfausk
Copy link

@benjamin-vauchel-webrivage FYI: I am using an adopted script for using related chrome driver version in my repo.
https://github.com/robertfausk/behat-panther-extension/blob/master/bin/updatePantherChromeDriver.sh

#!/usr/bin/env bash
# ensure that symfony/panther's chromeDriver matches installed chromium version
# this needs chromium and symfony/panther (in vendor folder) to be installed

cd /srv/api/vendor/symfony/panther/chromedriver-bin

chromiumVersion=$(chromium --product-version 2>&1;);
chromiumBrowserVersion=$(chromium-browser --product-version 2>&1;);
googleChromeVersion=$(google-chrome --product-version 2>&1;);
if [[ ${chromiumVersion} == *"."*"."* ]]; then
  chromiumVersion="$( cut -d '.' -f 1 <<< "$chromiumVersion" )";
  echo "Found chromium version ${chromiumVersion}";
  chromeDriverVersion="_${chromiumVersion}"
elif [[ ${chromiumBrowserVersion} == *"."*"."* ]]; then
  chromiumBrowserVersion="$( cut -d '.' -f 1 <<< "$chromiumBrowserVersion" )";
  echo "Found chromium-browser version ${chromiumBrowserVersion}";
  chromeDriverVersion="_${chromiumBrowserVersion}"
elif [[ ${googleChromeVersion} == *"."*"."* ]]; then
  googleChromeVersion="$( cut -d '.' -f 1 <<< "$googleChromeVersion" )";
  echo "Found google-chrome version ${googleChromeVersion}";
  chromeDriverVersion="_${googleChromeVersion}"
else
  "No google-chrome, chromium-browser or chromium found. Using latest release..."
  chromeDriverVersion=""
fi

chromeDriver=$(curl -s https://chromedriver.storage.googleapis.com/LATEST_RELEASE${chromeDriverVersion});
echo "Downloading ChromeDriver version ${chromeDriver} from https://chromedriver.storage.googleapis.com/LATEST_RELEASE${chromeDriverVersion} ..."

declare -a binaries=("chromedriver_linux64" "chromedriver_mac64" "chromedriver_win32")
for name in "${binaries[@]}"
do
   curl -s https://chromedriver.storage.googleapis.com/${chromeDriver}/${name}.zip -O
   unzip -q -o ${name}.zip
   rm ${name}.zip
   if [[ -f "chromedriver" ]]; then
      mv chromedriver ${name}
   fi
done

curl -s https://chromedriver.storage.googleapis.com/${chromeDriver}/notes.txt -O
echo "Done."

Maybe this helps.

@benjamin-vauchel-webrivage benjamin-vauchel-webrivage force-pushed the benjamin-vauchel-webrivage-patch-1 branch 2 times, most recently from 788c4db to afad962 Compare October 9, 2020 13:16
@benjamin-vauchel-webrivage
Copy link
Author

@robertfausk It seems Chrome latest stable version is not compatible anymore with Trusty release (https://travis-ci.community/t/you-can-no-longer-install-chrome-stable-on-trusty-machines/8521). I got an error "dpkg: error processing archive /tmp/google-chrome-stable_current_amd64.deb (--install):".

I'll try with Xenial and Bionic releases ...

@J-Ben87
Copy link

J-Ben87 commented Dec 29, 2020

Hi, thanks for the PR. I was struggling on the same issue, and ended up with a similar solution.

@sanpii could you please accept and merge the PR? This is quite a simple fix for quite a blocking issue.
Or maybe give us an advise on how to fix the tests?

Thanks 🙂

@J-Ben87
Copy link

J-Ben87 commented Jan 8, 2021

Hi @sanpii , did you consider merging this PR yet?

@J-Ben87
Copy link

J-Ben87 commented Jan 18, 2021

Up @sanpii ? That's a shame that we can't use this great bundle for such a little issue 🙁

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants