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

Support for chrome inspection of behat via debug port #300

Open
skodak opened this issue Aug 26, 2024 · 1 comment
Open

Support for chrome inspection of behat via debug port #300

skodak opened this issue Aug 26, 2024 · 1 comment

Comments

@skodak
Copy link
Contributor

skodak commented Aug 26, 2024

After reading about the new headless mode in chrome https://developer.chrome.com/docs/chromium/new-headless
I have tried to make it work in Moodle docker, but there was one unexpected problem: they have removed support for binding the debug port to different interfaces, it always listens only on the localhost address.

Changes needed:

  1. add port redirection to another interface in selenium - I did it by installing socat via apt and sudo socat TCP4-LISTEN:9223,fork TCP4:127.0.0.1:9222
  2. add new setting MOODLE_DOCKER_BROWSER_DEBUG_PORT and open ports to selenium when specified
  3. add changes to config.php to add chrome parameter remote-debugging-port=9222

More details in skodak@03a8021

Benefits compared to using VNC:

  • unlike VNC this works with chrome in new headless mode (and normal mode too)!
  • no problems with scaling and panning - the inspection view is scaled automatically, there is no need to set screen size
  • no need for a VNC clients - standard Chrome is used, just open chrome://inspect
  • the inspect view remembers your settings - such as open console to see JS errors while the test is progressing
  • it seems to work fine when selenium session is not closed properly - VNC shows multiple browser windows in that case until session time out

Known problems:

  • the port redirection in selenium I used is awkward, there must be a better way
  • the inspect view is not a real browser - for example I did not find how to do right-click yet (but it is not really necessary)
@skodak
Copy link
Contributor Author

skodak commented Aug 26, 2024

as it turns out the new headless chrome has problem scrolling overlay elements past the screen resolution

workaround is to increase default medium size in behat to 1440x1440 (some fragile tests might need tweaking afterwards)

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

No branches or pull requests

2 participants
@skodak and others