Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SETUP ISSUE] Invalid Chrome binary #763

Closed
Dev-Ditrict-Web opened this issue Nov 22, 2024 · 9 comments
Closed

[SETUP ISSUE] Invalid Chrome binary #763

Dev-Ditrict-Web opened this issue Nov 22, 2024 · 9 comments
Assignees

Comments

@Dev-Ditrict-Web
Copy link

Version 3.5
If you're opening an issue to report a breakage caused by version 3.5; please read the migration guide first first!

Environment
OS: Mac
PHP version: 8.2
Installed Codeception version: 5.1.2
Installed wp-browser version: 4.3
WordPress version: 6.6.2
Local development environment: DDEV (like VVV) docker containers
WordPress structure and management: default

Did you use the codecept init wpbrowser command?
Yes

Did you take a look at Codeception and wp-browser documentation?
I followed https://wpbrowser.wptestkit.dev/v3/tutorials/vvv-setup/#bootstrapping-and-configuring-wp-browser and when I init 'vendor/bin/codecept init wpbrowser' it breaks almost instantly with a error Chrome binary not executable or not existing

Codeception configuration file
not able to complete

Describe the issue you're encountering
I'm in a ddev environnement, and trying to configure wp-browser to work with my plugin. I followed https://wpbrowser.wptestkit.dev/v3/tutorials/vvv-setup/#bootstrapping-and-configuring-wp-browser and when I init 'vendor/bin/codecept init wpbrowser' it breaks almost instantly with a error Chrome binary not executable or not existing

Output

To Reproduce

Screenshots
If applicable, add screenshots to help explain your problem.
Screenshot 2024-11-22 at 9 56 07 AM

Additional context
Add any other context about the problem here.

@lucatume
Copy link
Owner

HI @Dev-Ditrict-Web,

Thank you for taking the time to open an issue and report the details.

I'm in a ddev environnement, and trying to configure wp-browser to work with my plugin. I followed https://wpbrowser.wptestkit.dev/v3/tutorials/vvv-setup/#bootstrapping-and-configuring-wp-browser [...]

You're using version 4 of wp-browser, that guide is applicable to version < 3.5, it's likely not applicable.

Is Chrome installed in the machine (the VM/container in this case) running wp-browser? Is it available in the PATH?
If it's not installed: can you try installing Chrome and trying the setup again?
If it's installed: what is the file path to the Chrome executable in the machine running wp-browser?

The wp-browser installer tried to find it in chromium and google-chrome and could find neither.

@Dev-Ditrict-Web
Copy link
Author

Hi @lucatume,

Thanks for your follow up.

Ok and there is newer tutorials on how to setup with the new version?

It used to work : https://github.com/orgs/ddev/discussions/4459

But I guess I'll look into adding a chromium or ggole-chrome in the containers.

I'll look into that.

@Dev-Ditrict-Web
Copy link
Author

I add Selenium Standalone Chrome: ddev add-on get ddev/ddev-selenium-standalone-chrome. in my ddev containers.

Still the wp-browser gives me the same error.

@lucatume
Copy link
Owner

@Dev-Ditrict-Web thanks for taking a further look.

I've done my own research and found the wp-config.php parsing logic requires a tweak to work correctly in ddev context.

I'm tracking the changes in the v4-wpconfig-env branch.
You can test the changes out with:

composer require --dev lucatume/wp-browser:dev-v4-wpconfig-env

With that, I could run the setup opting out of the default configuration.
This solution might be the one you're looking and will unblock you now. You will need to configure the tests/.env file manually and add/remove/edit the suites scaffolded for you (Integration and End-to-End).

To be able to use the default configuration, I've updated the project .ddev/config.yaml file to install Chromium in the web container:

- # webimage_extra_packages: [php7.4-tidy, php-bcmath]
+ webimage_extra_packages: [chromium, net-tools]

And could run the setup using the default configuration successfully after that

There is still an issue with Chromedriver not running correctly in the context of ddev I have to research., though.

I will update this issue with findings when I find out what is throwing Chromedriver off.

@lucatume
Copy link
Owner

I could set up things using the default configuration and run the Integration and the EndToEnd suite adding chromium-driver to the webimage_extra_packages option and configuring Codeception to use Chromedriver from the path:

- # webimage_extra_packages: [php7.4-tidy, php-bcmath]
+ webimage_extra_packages: [chromium, net-tools, chromium-driver]

After doing this I've re-built the ddev stack, run the default configuration and modified the codeception.yml file to the system Chromedriver binary:

namespace: Tests
support_namespace: Support
paths:
    tests: tests
    output: tests/_output
    data: tests/Support/Data
    support: tests/Support
    envs: tests/_envs
actor_suffix: Tester
params:
    - tests/.env
extensions:
    enabled:
        - Codeception\Extension\RunFailed
        - lucatume\WPBrowser\Extension\ChromeDriverController
        - lucatume\WPBrowser\Extension\BuiltInServerController
    config:
        lucatume\WPBrowser\Extension\ChromeDriverController:
            port: '%CHROMEDRIVER_PORT%'
+           binary: '%CHROMEDRIVER_BINARY%'
        lucatume\WPBrowser\Extension\BuiltInServerController:
            workers: 5
            port: '%BUILTIN_SERVER_PORT%'
            docroot: '%WORDPRESS_ROOT_DIR%'
            env:
                DATABASE_TYPE: sqlite
                DB_ENGINE: sqlite
                DB_DIR: '%codecept_root_dir%/tests/Support/Data'
                DB_FILE: db.sqlite
                WPBROWSER_SITEURL: '%WORDPRESS_URL%'
                WPBROWSER_HOMEURL: '%WORDPRESS_URL%'
    commands:
        - lucatume\WPBrowser\Command\RunOriginal
        - lucatume\WPBrowser\Command\RunAll
        - lucatume\WPBrowser\Command\GenerateWPUnit
        - lucatume\WPBrowser\Command\DbExport
        - lucatume\WPBrowser\Command\DbImport
        - lucatume\WPBrowser\Command\MonkeyCachePath
        - lucatume\WPBrowser\Command\MonkeyCacheClear
        - lucatume\WPBrowser\Command\DevStart
        - lucatume\WPBrowser\Command\DevStop
        - lucatume\WPBrowser\Command\DevInfo
        - lucatume\WPBrowser\Command\DevRestart
        - lucatume\WPBrowser\Command\ChromedriverUpdate

I've defined that in the tests/.env file (your ports will differ, but that is not relevant here):

# The path to the WordPress root directory, the one containing the wp-load.php file.
# This can be a relative path from the directory that contains the codeception.yml file,
# or an absolute path.
WORDPRESS_ROOT_DIR=.

# Tests will require a MySQL database to run.
# The database will be created if it does not exist.
# Do not use a database that contains important data!
WORDPRESS_DB_URL=sqlite://%codecept_root_dir%/tests/Support/Data/db.sqlite

# The Integration suite will use this table prefix for the WordPress tables.
TEST_TABLE_PREFIX=test_

# This table prefix used by the WordPress site in end-to-end tests.
WORDPRESS_TABLE_PREFIX=wp_

# The URL and domain of the WordPress site used in end-to-end tests.
WORDPRESS_URL=http://localhost:15723
WORDPRESS_DOMAIN=localhost:15723
WORDPRESS_ADMIN_PATH=/wp-admin

# The username and password of the administrator user of the WordPress site used in end-to-end tests.
WORDPRESS_ADMIN_USER=admin
WORDPRESS_ADMIN_PASSWORD=password

# The host and port of the ChromeDriver server that will be used in end-to-end tests.
+ CHROMEDRIVER_BINARY=/usr/bin/chromedriver
CHROMEDRIVER_HOST=localhost
CHROMEDRIVER_PORT=42706

# The port on which the PHP built-in server will serve the WordPress installation.
BUILTIN_SERVER_PORT=15723

Note: I could only run end-to-end tests reliably on my x86 machine; Linux on arm64 does work, but does so intermittently due to communication issues between Chromium and Chromedriver. I suspect this is due to the fact that Linux on ARM64 is not supported.

@lucatume
Copy link
Owner

I've merged #766 and released that in version 4.3.9.

@Dev-Ditrict-Web
Copy link
Author

Hi @lucatume,

Thanks for the merge!

I'll test that right away

@Dev-Ditrict-Web
Copy link
Author

it did install properly. @lucatume Thanks!

@lucatume
Copy link
Owner

lucatume commented Dec 3, 2024

Excellent, thanks @Dev-Ditrict-Web for the confirmation.

Should you run into other problems, open a new issue.

@lucatume lucatume closed this as completed Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants