Score:0

Mink unable to connect to chromedriver

ai flag

I need help from someone who knows about testing web pages with Javascript in Docker containers. I have browser-based testing working and now I have scenarios which don't work without Javascript, so I'm trying to follow the Drupal documentation for running PHPUnit Javascript tests. The problem is that I'm getting

An unexpected error occurred while starting Mink: unknown error: net::ERR_CONNECTION_REFUSED

I can see that the chrome container is listening on port 9515:

# ss -a | grep 9515
tcp   LISTEN    0      5        *:9515              *:*

And I have confirmed that the web container can in fact connect to it on that port:

# curl --head http://chrome:9515
HTTP/1.1 404 Not Found
Content-Length:545
Content-Type:application/json; charset=utf-8
cache-control:no-cache

The MINK_DRIVER_ARGS_WEBDRIVER variable is set in phpunit.xml as instructed by the documentation linked above:

<env name="MINK_DRIVER_ARGS_WEBDRIVER" value='["chrome", {"browserName":"chrome","chromeOptions":{"args":["--disable-gpu","--headless", "--no-sandbox", "--disable-dev-shm-usage"]}}, "http://chrome:9515"]'/>

I can't run chromedriver directly in the web container, because it's running Ubuntu, which says you have to install the chromium snap, and Docker containers don't support snap. So I used the Other ways to install and run chromedriver: Docker compose based chromedriver instructions from the documentation linked above to put it in a separate container.

I'm out of my depth here. Help, please!

Kevin avatar
in flag
You may find some ideas on this from DTT: https://gitlab.com/weitzman/drupal-test-traits i.e. adapting from its docker-compose: https://gitlab.com/weitzman/drupal-test-traits/-/blob/2.x/.ddev/docker-compose.selenium-chrome.yaml
Score:1
cn flag

The "easiest" (depending on your setup, it may not be all that easy) is to use the selenium-standalone-chrome docker image.

This image contains chrome as well as VNC for watching your tests.

Ddev has this image available as a plugin. Ddev is probably the simplest way to get set up, although you may need to remove the --headless flag from the plugin configuration to get core tests working.

ai flag
Thanks, @Patrick_Kenny. My first line of attack is going to be trying to figure out how the components work under the covers in the hopes of finding out what I'm (or possibly they're) doing wrong. If I hit a brick wall in that direction, I'll fall back on trying out other black boxes to see if they'll work better. This one looks promising.
ai flag
I decided to mark this as the accepted answer, as it got me a good bit of the way to a working setup. I'm not using `ddev`, as I already have containers for the rest of the system (web, database, mail), and `selenium/standalone-chrome` doesn't support arm64, but there's a [fork](https://github.com/seleniumhq-community/docker-seleniarm) which does, and that's what I'm using. Thanks for the nudge in the right direction, @Patrick_Kenny.
ai flag
I still don't understand how Apache knows which requests should use the separate test instance of the site, and which should be handled by the fully-built site reachable from the host machine, as both types of request are showing up in the same Apache access log, but that would be out of scope for this question. ️
cn flag
@BobKline Glad you were able to improve your setup. Note that `ddev` will automatically use arm64 images when run on an arm machine, including for `selenium/standalone-chrome`. So for anyone reading this who is considering using ddev on arm, you can do so with no additional work required.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.