Skip to content

Commit

Permalink
Merge pull request #24 from robertfausk/upgrade_usable_chromedriver_v…
Browse files Browse the repository at this point in the history
…ersion

Upgrade usable chromedriver version
  • Loading branch information
robertfausk committed Jun 6, 2022
2 parents 1373292 + 8d27eb7 commit 9736379
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/ci.yml
Expand Up @@ -19,7 +19,6 @@ jobs:
fail-fast: false
env:
MATRIX_PHP: ${{ matrix.php }}
PANTHER_CHROME_BINARY: '/opt/hostedtoolcache/chromium/858016/x64/chrome'
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -37,15 +36,10 @@ jobs:
run: |
composer install --no-interaction --no-scripts --no-progress --prefer-dist
- uses: browser-actions/setup-chrome@latest
with:
chrome-version: 858016
- run: chrome --version
- name: Uninstall chromedriver from Ubuntu
run: |
sudo apt-get remove chromium-chromedriver
- name: Add browser drivers
run: |
vendor/bin/bdi driver:chromedriver --driver-version=90.0.4430.24 drivers
vendor/bin/bdi driver:chromedriver drivers
- name: Setup Mink test server
run: |
mkdir ./logs
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -87,6 +87,6 @@ Best way to bypass this problem is to update them to their newest version.
## Credits

Created by Robert Freigang [robertfausk](https://github.com/robertfausk).

MinkPantherDriver is built on top of [Panther](https://github.com/symfony/panther) and for usage with [Behat and Mink](http://behat.org/en/latest/cookbooks/integrating_symfony2_with_behat.html#initialising-behat).
It has been inspired by [MinkBrowserKitDriver](https://github.com/minkphp/MinkBrowserKitDriver) and [MinkSelenium2Driver](https://github.com/minkphp/MinkSelenium2Driver).
6 changes: 6 additions & 0 deletions composer.json
Expand Up @@ -21,6 +21,12 @@
"email": "robertfreigang@gmx.de"
}
],
"repositories": [
{
"type": "vcs",
"url": "https://github.com/robertfausk/panther"
}
],
"require": {
"php": ">=7.2",
"behat/mink": "~1.8",
Expand Down
28 changes: 16 additions & 12 deletions src/PantherDriver.php
Expand Up @@ -13,10 +13,13 @@

use Behat\Mink\Exception\DriverException;
use Behat\Mink\Exception\UnsupportedDriverActionException;
use Facebook\WebDriver\Exception\UnsupportedOperationException;
use Facebook\WebDriver\Interactions\Internal\WebDriverCoordinates;
use Facebook\WebDriver\Interactions\WebDriverActions;
use Facebook\WebDriver\Internal\WebDriverLocatable;
use Facebook\WebDriver\JavaScriptExecutor;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\Remote\RemoteWebElement;
use Facebook\WebDriver\WebDriverDimension;
use Facebook\WebDriver\WebDriverElement;
use Facebook\WebDriver\WebDriverHasInputDevices;
Expand Down Expand Up @@ -470,6 +473,18 @@ public function getOuterHtml($xpath)
{
$crawler = $this->getFilteredCrawler($xpath);

$crawlerElement = $this->getCrawlerElement($crawler);
if ($crawlerElement instanceof RemoteWebElement) {
$webDriver = $this->client->getWebDriver();
if ($webDriver instanceof RemoteWebDriver && $webDriver->isW3cCompliant()) {
try {
return $crawlerElement->getDomProperty('outerHTML');
} catch (UnsupportedOperationException $e) {
throw new DriverException($e->getMessage(), $e->getCode(), $e);
}
}
}

return $crawler->html();
}

Expand All @@ -480,18 +495,7 @@ public function getAttribute($xpath, $name)
{
$crawler = $this->getFilteredCrawler($xpath);

$attribute = $this->getCrawlerElement($crawler)->getAttribute($name);

// let's get hacky
if ('' === $attribute) {
$html = \strtolower($crawler->html());
$name = \strtolower($name).'=';
if (0 === \substr_count($html, $name)) {
$attribute = null;
}
}

return $attribute;
return $this->getCrawlerElement($crawler)->getAttribute($name);
}

/**
Expand Down

0 comments on commit 9736379

Please sign in to comment.