Skip to content

Support for chrome inspection of behat via debug portΒ #300

@skodak

Description

@skodak

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 https://github.com/skodak/moodle-docker/commit/03a8021a8cb676359c72817f139f98acc35b47cf

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions