Running Browser in docker

Hello,

I’m trying to establish a docker-image with robotframework-browser and nodejs. I’m bit puzzled what is wrong when running following sample test. At least rfbrowser init is passing when it’s run in container (debian, docker desktop with WSL2).

Same test in host-machine (win10) produced similar errors as below, but it got sorted by supplying s proxy setting. The same gotcha seem not suffice for docker-container.

npm config set https-proxy http://proxy…/

  • Would you have advice what to try next ?

This kind “could not connect error” keeps repeating, with different port numbers

[ ERROR ] Calling method ‘_start_suite’ of listener ‘Browser’ failed: Could not connect to the playwright process at port 40583.

RF debug-log shows this

<_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = “failed to connect to all addresses”
debug_error_string = “{“created”:”@1621861387.280764500",“description”:“Failed to pick subchannel”,“file”:“src/core/ext/filters/client_channel/client_channel.cc”,“file_line”:5419,“referenced_errors”:[{“created”:"@1621861387.280701100",“description”:“failed to connect to all addresses”,“file”:“src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc”,“file_line”:397,“grpc_status”:14}]}"

*** Settings ***
Library Browser

*** Test Cases ***
Starting a browser with a page
New Browser chromium headless=true
New Context viewport={‘width’: 1920, ‘height’: 1080}
New Page https://marketsquare.github.io/robotframework-browser/Browser.html
Get Title == Browser

rfbrowser init completed
root@60e0252cc2ff:/home/jenkins/tests/Tests/me# robot test.robot

Test

[ ERROR ] Calling method ‘_start_suite’ of listener ‘Browser’ failed: Could not connect to the playwright process at port 40583.
[ ERROR ] Calling method ‘_start_test’ of listener ‘Browser’ failed: Could not connect to the playwright process at port 58665.
Starting a browser with a page | FAIL |
Could not connect to the playwright process at port 59053.

root@60e0252cc2ff:/home/jenkins/tests/Tests/me# nodejs --version
v14.17.0
root@60e0252cc2ff:/home/jenkins/tests/Tests/me# npm --version
6.14.13

pip list |grep robot
robotframework 4.0.1
robotframework-assertion-engine 0.0.6
robotframework-browser 5.0.0
robotframework-pabot 1.13
robotframework-pythonlibcore 2.2.1
robotframework-requests 0.9.1
robotframework-seleniumlibrary 5.1.3
robotframework-xvfb 1.2.2

Hi Ilmo,

When I had a go at getting robot framework selenium library working in docker containers the trick was getting the x windows configured and behaving.

That error indicates the browserlibrary in robot framework couldn’t connect to the browser process being controlled by playwright (if i’m understanding it properly) I had similar errors to this because the browser process would crash on launch because it couldn’t find a window server (even with the headless options you still need the window server)

I found example docker files that did things like this:

COPY entry_point.sh /opt/bin/entry_point.sh

ENV SCREEN_WIDTH 1280
ENV SCREEN_HEIGHT 720
ENV SCREEN_DEPTH 16


USER 0
RUN chmod +x /opt/bin/entry_point.sh

with entry_point.sh having these lines in it

GEOMETRY="${SCREEN_WIDTH}x${SCREEN_HEIGHT}x${SCREEN_DEPTH}"
Xvfb :99 -screen 0 $GEOMETRY &
export DISPLAY=:99

Hope that helps,

Dave.

Thx Dave for your reply

I’ve checked frame-buffer and it’s started by entry_point.sh

root@2b12ba5b6a6d:/home/jenkins# ps aux |grep Xv
root 16 0.0 0.1 705572 44436 pts/0 Sl 07:28 0:00 Xvfb :99 -screen 0 1920x1080x16

However it still stumbles on this :frowning:
[ ERROR ] Calling method ‘_start_suite’ of listener ‘Browser’ failed: Could not connect to the playwright process at port 58841.

Hi Ilmo,

I think you also need to run robot from the entry_point.sh so that everything starts in that session, so you probably need to setup a variable to any options to robot.

I can’t find the article I read now, where I got this information, but google “docker robotframework selenium” and you’ll find quite a few examples, you just need to replace the selenium parts with browser library parts.

Also it might be worth googling google “docker robotframework browser” or variations and see if anyone has done it already (but from my quick searches it doesn’t look like it)

This was actually on my todo list but it’s a fair way down the list.

Dave.

This looks familiar case.

Case suggests some issue with gRPC

These come with Browser and are fairly new
grpcio 1.37.1
grpcio-tools 1.37.1

root@docker-desktop:/home/jenkins/tests/Tests/me# npm list |grep grp
├─┬ @grpc/grpc-js@1.3.2
├─┬ grpc@1.24.10

if http_proxy and https_proxy are unset, “connect to playwright” error stops. Without proxy curling to some URL fails, and so will playwright timeout since connections to outside require that setting.

btw.
playwright-log.txt seem to display just one line. It is as if log is overwritten first row over and over. In below sample you’d expect there’d be at least three entries, since three different playwright ports are outputted. Last line refers to method _close.

root@docker-desktop:/home/jenkins/tests/Tests/me# robot test.robot

Test

[ ERROR ] Calling method ‘_start_suite’ of listener ‘Browser’ failed: Could not connect to the playwright process at port 48465.
[ ERROR ] Calling method ‘_start_test’ of listener ‘Browser’ failed: Could not connect to the playwright process at port 36411.
Starting a browser with a page | FAIL |
Could not connect to the playwright process at port 43857.

Test | FAIL |
1 test, 0 passed, 1 failed

[ ERROR ] Error in library ‘Browser’: Calling method ‘_close’ of listener ‘Browser’ failed: Could not connect to the playwright process at port 45541.
Output: /home/jenkins/tests/Tests/me/output.xml
Log: /home/jenkins/tests/Tests/me/log.html
Report: /home/jenkins/tests/Tests/me/report.html

root@docker-desktop:/home/jenkins/tests/Tests/me# cat playwright-log.txt
{“level”:30,“time”:“2021-05-27T10:45:59.565Z”,“pid”:2866,“hostname”:“docker-desktop”,“msg”:“Listening on 45541”}

Hi Ilmo,

In that issue (#460) you linked, there was another issue linked (#466) where there was mention of a docker image on dockerhub did you try this docker image? if it doesn’t do everything you need you should try making an image using this as your base.

Hope you get it working,

Dave.

I’m adding a ticket. There must be some thing to fix in presence of a proxy-setting Playwright process connection in container fails when proxy is set .. client_channel/lb_policy/pick_first/pick_first.cc","file_line":397,"grpc_status":14 · Issue #1037 · MarketSquare/robotframework-browser · GitHub

Hello again,

A observation for grpc. One can actually circumvent the proxy-problem in container by giving ‘any’ value to variable which is found in above source code: grpc_proxy.

  1. Browser-test will pass in container export grpc_proxy=https://localhost:8080
  2. But so will this as well … export grpc_proxy=jsdflkjhsdhljkgfd

Above indicates that there’s error handling for grpc that defaults grpc not to use proxy, which is required since this is happening locally in container. Connections to the world go thru proxies as they need.

And ultimately this Browser/container/proxy combo works simply by adding localhost to no_proxy entries… Seems that 127.0.0.1 doesn’t suffice for this … ?

export no_proxy=.nnnn.com,0.0.0.0,127.0.0.1,.nnnn.local,localhost