GithubHelp home page GithubHelp logo

dbrekelmans / browser-driver-installer Goto Github PK

View Code? Open in Web Editor NEW
44.0 44.0 11.0 800 KB

Helps you install the appropriate browser driver

License: MIT License

PHP 100.00%
browser-driver chromedriver hacktoberfest

browser-driver-installer's People

Contributors

chris53897 avatar dbrekelmans avatar gurdarrag avatar kbond avatar kevinvansonsbeek avatar laurent35240 avatar mocodo avatar nclshart avatar nusje2000 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

browser-driver-installer's Issues

Upgrade from PHP 8.0 to 8.1.1 broke bdi

Since upgrading from PHP 8.0 to 8.1.1, I get the following:

./vendor/bin/bdi detect drivers -vvv

Box Requirements Checker
========================

> Using PHP 8.1.1
> PHP is using the following php.ini file:
  /etc/php/8.1/cli/php.ini

> Checking Box requirements:
  ✔ The application requires the version "^7.2|^8.0" or greater.
  ✔ The application requires the extension "json".
  ✔ The package "myclabs/php-enum" requires the extension "json".
  ✔ The application requires the extension "zip".
  ✔ The application requires the extension "zlib".
  
                                                                                
 [OK] Your system is ready to run the application.                              
                                                                                

Found google-chrome 97.0.4692.71.

                                                                                                                        
 [WARNING] Could not execute command "browser:google-chrome".                                                           
                                                                                                                        

Something went wrong getting the driver version from the chromedriver API.

                                                                                                                        
 [WARNING] Could not execute command "browser:chromium".                                                                
                                                                                                                        

Version could not be determined.
Found firefox 96.0.

                                                                                                                        
 [WARNING] Could not execute command "browser:firefox".                                                                 
                                                                                                                        

fopen(): Invalid IP Address: 0

The commands ./vendor/bin/bdi driver:chromedriver and ./vendor/bin/bdi driver:geckodriver produce the following:

In ErrorChunk.php line 65:
                                  
  fopen(): Invalid IP Address: 0  
                                  

In NativeResponse.php line 120:
                                  
  fopen(): Invalid IP Address: 0  

All my PHPUnit tests still are successful, so I doubt that it's my PHP installation that's faulty.

Command: driver:chrome

Add a driver:chrome command to install chrome driver directly (without checking for compatible browser version).
With required argument version that either specifies a version string (x.x.x) or latest

Firefox support

Depends on #37.

With gecko driver supported, we can build in support for firefox.

Support PHP 7.1

Since symfony/panther supports PHP 7.1, we are also required to support it in order for panther to be able to require this library.

Support Chromium

In order to support Chromium, a few things need to happen:

  • Create src/Browser/Chromium/PathResolver
  • Create src/Browser/Chromium/VersionResolver
  • Register pathresolver to factory in install.php
  • Register versionresolver to factory in install.php

Chromium can work with the already existing ChromeDriver.

As an example, you can look at how GoogleChrome is implemented.

Library is deprecated on PHP 8.1

Discussed in #63

Originally posted by mkrizanec-undabot December 29, 2022
@dbrekelmans

Hello, are you planning to update this library to work with PHP 8.1?

Specificaly, I'm using it with Panther and detect drivers method doesn't work anymore.

**Deprecated: Return type of HumbugBox385\KevinGH\RequirementChecker\RequirementCollection::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///opt/app/vendor/dbrekelmans/bdi/bdi/.box/src/RequirementCollection.php on line 15

Deprecated: Return type of HumbugBox385\KevinGH\RequirementChecker\RequirementCollection::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///opt/app/vendor/dbrekelmans/bdi/bdi/.box/src/RequirementCollection.php on line 19

Deprecated: Return type of MyCLabs\Enum\Enum::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///opt/app/vendor/dbrekelmans/bdi/bdi/vendor/myclabs/php-enum/src/Enum.php on line 246**

Support php 7.2

A lot of projects still run on php versions lower than 7.4. Let's enable them to use this tool by supporting at least 7.2. Most likely the only change will be typed properties -> docblocks.

Bug: chrome driver "latest" detection uses outdated api endpoint

While testing around i noticed that running the bdi driver:chrome ended up installing version 114.0.5735.90.

The api endpoint that is called for finding the last version (https://chromedriver.storage.googleapis.com/LATEST_RELEASE) seems to have stopped updating when they migrated to the new json endpoints.

We can now resolve the latest stable version though https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json.

Could not parse version string on windows

The command bdi browser:google-chrome is not working on windows.

In Version.php line 41:
                                        
  [InvalidArgumentException]            
  Could not parse version string "��
\  
  \
\                                   
  \".     
Exception trace:
  at D:\a\browser-driver-installer\browser-driver-installer\src\Version.php:41
 DBrekelmans\BrowserDriverInstaller\Version::fromString() at D:\a\browser-driver-installer\browser-driver-installer\src\Browser\GoogleChrome\VersionResolver.php:58
 DBrekelmans\BrowserDriverInstaller\Browser\GoogleChrome\VersionResolver->getVersionFromCommandLine() at D:\a\browser-driver-installer\browser-driver-installer\src\Browser\GoogleChrome\VersionResolver.php:33
 DBrekelmans\BrowserDriverInstaller\Browser\GoogleChrome\VersionResolver->from() at D:\a\browser-driver-installer\browser-driver-installer\src\Browser\BrowserFactory.php:36
 DBrekelmans\BrowserDriverInstaller\Browser\BrowserFactory->createFromNameOperatingSystemAndPath() at D:\a\browser-driver-installer\browser-driver-installer\src\Browser\BrowserFactory.php:27
 DBrekelmans\BrowserDriverInstaller\Browser\BrowserFactory->createFromNameAndOperatingSystem() at D:\a\browser-driver-installer\browser-driver-installer\src\Command\BrowserCommand.php:72
 DBrekelmans\BrowserDriverInstaller\Command\BrowserCommand->execute() at D:\a\browser-driver-installer\browser-driver-installer\vendor\symfony\console\Command\Command.php:258
 Symfony\Component\Console\Command\Command->run() at D:\a\browser-driver-installer\browser-driver-installer\vendor\symfony\console\Application.php:920
 Symfony\Component\Console\Application->doRunCommand() at D:\a\browser-driver-installer\browser-driver-installer\vendor\symfony\console\Application.php:266
 Symfony\Component\Console\Application->doRun() at D:\a\browser-driver-installer\browser-driver-installer\vendor\symfony\console\Application.php:142
 Symfony\Component\Console\Application->run() at D:\a\browser-driver-installer\browser-driver-installer\bdi:42

Autodetect the browsers to support

It could be nice to install all drivers for all installed browsers by default (php install). It would help, at least with Panther, to run the same test suite with different browsers.

Also, maybe can the command name be a bit more explicit? Such as php vendor/bin/install-browser-drivers?

BDI fails with chromedriver 109+ (More than on file in zip)

Hello,

I just ran into an issue : chromedriver 109+ now contains a license file in the zip :
image
(i.ie. : https://chromedriver.storage.googleapis.com/109.0.5414.74/chromedriver_linux64.zip)

BDI fails if more than one file is contained in the zip.

Error message :

In Downloader.php line 72:
                                                             
  Something went wrong extracting the chromedriver archive.  
                                                             
In Downloader.php line 175:
                                                     
  Expected exactly one file in the archive. Found 2  
                                                     
browser:google-chrome [--os OS] [--browser-path BROWSER-PATH] [--] [<install-path>]

Could we extract the only file named "chromedriver" ? Or is there an edge case (pun intended)?

Google chrome driver endpoint changed.

The Downloader for the ChromeDriver uses https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing as endpoint for the downloads.

Google seems to have changed this domain to https://storage.googleapis.com/chrome-for-testing-public/.

A quick fix would be to just change the download endpoint. But possibly we should look into the option to resolve the download url, from the page we use to resolve the versions?

Edit:
This change seems to have been made between patches 121.0.6166 and 121.0.6167

Browser is not detected on Alpine

FROM php:8.1-alpine
WORKDIR /app
RUN apk add libzip-dev $PHPIZE_DEPS
RUN pecl install xdebug && docker-php-ext-enable xdebug
RUN docker-php-ext-install bcmath zip

COPY --from=phpbuild /app/vendor /app/vendor
COPY --from=jsbuild /app/public/build /app/public/build

# Chromium and ChromeDriver
ENV PANTHER_NO_SANDBOX 1
# Not mandatory, but recommended
ENV PANTHER_CHROME_ARGUMENTS='--disable-dev-shm-usage'
RUN apk add --no-cache chromium 

CMD tail -f /dev/null

Browser will be installed as chromium-browser not chromium.
Adding ln -s $(which chromium-browser) /usr/bin/chromium after install fixes the issue

Add the possibility to use custom directory

Currently, there is no way (AFAIK) to set where the drivers will be installed.

It's not even consistent across commands, for example on my machine:

vendor/bin/bdi detect drivers
[OK] geckodriver 0.33.0 installed to drivers\geckodriver.exe

But this installs it on the project root:

vendor/bin/bdi driver:chromedriver
[OK] chromedriver 114.0.5735.90 installed to .\chromedriver.exe

It would be useful to have the possibility to read a .env variable with the path, for example one may want tests/drivers/

Unit tests: Google Chrome

We need unit tests for:

  • DBrekelmans\BrowserDriverInstaller\Browser\GoogleChrome\PathResolver
  • DBrekelmans\BrowserDriverInstaller\Browser\GoogleChrome\VersionResolver

CI: RateLimit for GitHub API

Many CI runs fail, because of the RateLimit for GitHub API.
Maybe someone can help with this problem.

 HTTP/1.1 403 rate limit exceeded returned for "https://api.github.com/repos  
  /mozilla/geckodriver/releases/latest".               

Unit tests: ChromeDriver

We need unit tests for:

  • DBrekelmans\BrowserDriverInstaller\Driver\ChromeDriver\Downloader
  • DBrekelmans\BrowserDriverInstaller\Driver\ChromeDriver\VersionResolver

Error immediately after installation

I'm getting the following error when I run vendor/bin/bdi detect drivers immediately after composer require --dev dbrekelmans/bdi. The installation of the package runs successfully, but detect drivers crashes with this message:

Fatal error: Uncaught TypeError: trim(): Argument #1 ($string) must be of type string, bool given in phar:///vendor/dbrekelmans/bdi/bdi/.box
/src/Terminal.php:60
Stack trace:
#0 phar:///vendor/dbrekelmans/bdi/bdi/.box/src/Terminal.php(60): trim(false)
#1 phar:///vendor/dbrekelmans/bdi/bdi/.box/src/Terminal.php(31): HumbugBox436\KevinGH\RequirementChecker\Terminal::initDimensions()
#2 phar:///vendor/dbrekelmans/bdi/bdi/.box/src/Printer.php(28): HumbugBox436\KevinGH\RequirementChecker\Terminal->getWidth()
#3 phar:///vendor/dbrekelmans/bdi/bdi/.box/src/Checker.php(17): HumbugBox436\KevinGH\RequirementChecker\Printer->__construct(32, true)
#4 phar:///vendor/dbrekelmans/bdi/bdi/.box/bin/check-requirements.php(22): HumbugBox436\KevinGH\RequirementChecker\Checker::checkRequirement
s()
#5 F:\Office\Amro Suboh\Codraft\Codraft\back\vendor\dbrekelmans\bdi\bdi(12): require('phar://F:/Offic...')
#6 F:\Office\Amro Suboh\Codraft\Codraft\back\vendor\bin\bdi(120): include('F:\\Office\\Amro ...')
#7 {main}
  thrown in phar:///vendor/dbrekelmans/bdi/bdi/.box/src/Terminal.php on line 60

I'm using PHP 8.2 on XAMPP and Windows 11. This is a Laravel 10 project if that has anything to do. I'm using latest version (1.0.5) of this package.

Work around rate limiting of firefox github repo in tests

Add a TokenRegistry where we can set a github token via the commands. The commands would receive this token as a command option. In the Downloader and VersionResolver, we can use the token from the registry (if it is set) to do the API calls. The TokenRegistry would be injected into the Downloader and VersionResolver via DI.

PHP Fatal error during platform check

Since v1.0.5 I encountered this error on MacOs and Docker (Linux alpine image)

PHP Fatal error:  Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1.0". You are running 8.0.30. in phar:///..../.composer/vendor/dbrekelmans/bdi/bdi/vendor/composer/platform_check.php on line 24

Here is the detailed output :

# composer global exec bdi -vvv

> __exec_command: bdi
Executing command (CWD): bdi

Box Requirements Checker
========================

> Using PHP 8.0.30
> PHP is using the following php.ini file:
  /usr/local/etc/php/8.0/php.ini

> Checking Box requirements:
  ✔ The application requires a version matching "^7.2|^8.0".
  ✔ The application requires the extension "json".
  ✔ The package "myclabs/php-enum" requires the extension "json".
  ✔ The application requires the extension "zip".
  ✔ The application requires the extension "zlib".
  ✔ The package "symfony/service-contracts" conflicts with the extension "psr".
  
                                                                                                                                                                                                                                   
 [OK] Your system is ready to run the application.                                                                                                                                                                                 
                                                                                                                                                                                                                                   

PHP Fatal error:  Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1.0". You are running 8.0.30. in phar:///Users/prometee/.composer/vendor/dbrekelmans/bdi/bdi/vendor/composer/platform_check.php on line 24

Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1.0". You are running 8.0.30. in phar:///Users/prometee/.composer/vendor/dbrekelmans/bdi/bdi/vendor/composer/platform_check.php on line 24
Script bdi handling the __exec_command event returned with error code 255

Using the v1.0.4 no issue encountered.

Support Chromedriver Mac ARM

Mac ARM now has its own chromedriver binary in chromedriver_mac_arm64.zip. The easiest way to support this is to add MacARM as a new operating system

Feature: Resolve chrome download url from api call

There is an api endpoint https://googlechromelabs.github.io/chrome-for-testing/latest-patch-versions-per-build-with-downloads.json that lists the url from which a specific version can be downloaded.

It would be a nice improvement to base the download url, on the response from the api. Instead of hard coded download url's, as those are more prone to failure, whenever they decide to change it again. (Like what happened last thursday, but they quickly fixed in the same day)

Use resolved path in windows to determine version

Currently, the chrome version is resolved based on some registry keys. This does not take into account the installed path and will cause incorrect versions if the user specifies custom browser path via the command.

The version resolver should work based on the provided path, instead of independently.

"Could not execute command" errors

Hello, I'm having trouble getting started and could use some help. I suspect that the problem is related to my environment, which is inside a ddev container.

Here are the setup commands I'm running in Windows WSL2 to start the environment:

ddev config --project-type=drupal9 --docroot=web --create-docroot
ddev start

Then I install and run bdi:

ddev composer require --dev dbrekelmans/bdi
ddev exec vendor/bin/bdi detect drivers -vvv

And that's when I get the errors:

Box Requirements Checker
========================

> Using PHP 8.0.26
> PHP is using the following php.ini file:
  /etc/php/8.0/cli/php.ini

> Checking Box requirements:
  ✔ The application requires the version "^7.2|^8.0" or greater.
  ✔ The application requires the extension "json".
  ✔ The package "myclabs/php-enum" requires the extension "json".
  ✔ The application requires the extension "zip".
  ✔ The application requires the extension "zlib".

 [OK] Your system is ready to run the application.


 [WARNING] Could not execute command "browser:google-chrome".

Command google-chrome --version failed

 [WARNING] Could not execute command "browser:chromium".

Version could not be determined.

 [WARNING] Could not execute command "browser:firefox".

Command firefox --version failed

Here are my PHP/Composer versions in case it is helpful:

$ ddev exec php --version
PHP 8.0.26 (cli) (built: Dec  5 2022 21:59:43) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.26, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.26, Copyright (c), by Zend Technologies
$ ddev composer --version
Composer version 2.5.4 2023-02-15 13:10:06

Please let me know if there's anything else I can provide that might help!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.