Why is my Dockerized Browserless-Chrome hanging when a Mediawiki Selenium test causes a new page to be loaded?

Viewed 240

Background

I have a makefile which fetches and spins up a Dockerized Mediawiki instance on my local machine, from scratch, with a single make command:

https://gitlab.wikimedia.org/mhurd/mediawiki-docker-make

This works fairly well. Please try it!

Goal

I'd also like to be able to run Mediawiki's Selenium tests (as-is) in Docker containers and watch them execute "live", with the makefile, again, making it easy to kick this process off.

Approach

This work-in-progress branch adds a container for running Mediawiki Selenium tests, and a browserless-chrome container so you can watch and debug the tests "live", as they run:

https://gitlab.wikimedia.org/mhurd/mediawiki-docker-make/-/tree/selenium

As you can see from the top of this branch's readme, after running make to spin everything up, running make runseleniumtests kicks the tests off. When doing so a browser window is automatically opened which lets you see the Selenium tests which are running in the browserless-chrome container. This works... to a point.

Problem

Unfortunately, after a few tests are seen to be running, I'm seeing this error:

Protocol error (Input.dispatchMouseEvent): Target closed.



I suspect the way the browserless-chrome container manages its Chrome sessions may be to blame, as it appears the error is happening when a test causes a new page to be loaded, but I'm not sure.

Any ideas appreciated, and please try it yourself - the whole point of the makefile is to make spinning this up from scratch super simple. It only takes a couple commands and you should be able to see the tests running and the resulting error. Thanks!

Misc

Running curl -s http://127.0.0.1:3000/sessions | python3 -m json.tool on the host machine after attempting to run the tests shows there are multiple browserless-chrome sessions, but I'm unsure how to make it behave more like a non-dockerized setup - which has no problem with tests which cause page loads.

In email communication with Browserless support, they mention seeing similar issues but haven't been able to track down why:

It seems to be that the root cause may be due to "click" events aren't working properly when your viewing the live debugger. Can you confirm that if you don't open the live viewer, it allows the test to progress and eventually throws new errors regarding selectors not being found? (Edit: I did)

I've also run into this live debugger behavior before and in my experience I stopped watching the live debugger, and since I couldn't see which selector it wasn't finding I exported a screenshot and in that particular case, it ended up being an issue with my viewport, since the viewport in the remote session was smaller, the styles rendered differently then locally on my machine, when I set the viewport size, the selectors were found - but then again, that was my particular issue, might not be yours.

But yes, for some odd reason when you view live sessions, you can run into this odd issue which we haven't been able to understand.

0 Answers
Related