Selenium grid with docker : Add Safari Node

Viewed 743

I need some documentation or experience for answer my question :

We have a grid server on a specific vm with chrome, firefox and edge driver, and it's working good.

Now we want to add safari browser to our test suite. We bought a apple mac m1, and we don't know how we can add safari browser.. if someone has a tutorial or explanation?

I try to start with a docker-compose like this on my mac :

version: "3"

services: 
  selenium-safari:
    image: selenium/node-base:4.1.3-20220327
    container_name: selenium-safari
    shm_size: "2g"
    environment: 
    - SE_EVENT_BUS_HOST=GRID-IP
    - SE_EVENT_BUS_PUBLISH_PORT=4442
    - SE_EVENT_BUS_SUBSCRIBE_PORT=4443
    - SE_NODE_HOST=IPOFMYMAC
    - SCREEN_WIDTH=1920 
    - SCREEN_HEIGHT=1080
    ports: 
    - 5555:5555
    volumes: 
    - ./config.toml:/opt/selenium/config.toml

and my config.toml into my container looks like :

[events]
publish = "tcp://GRID-IP:4442"
subscribe = "tcp://GRID-IP:4443"

[server]
host = "MYMACIP"
[node]
session-timeout = "300"
override-max-sessions = false
detect-drivers = false
max-sessions = 1

[[node.driver-configuration]]
display-name = ""
stereotype = '{"browserName": "", "browserVersion": "", "platformName": "Linux"}'
max-sessions = 1

but it's doesn't work :

Starting Selenium Grid Node...
selenium-safari    | 14:21:56.616 INFO [LoggingOptions.configureLogEncoding] - Using the system default encoding
selenium-safari    | 14:21:56.639 INFO [OpenTelemetryTracer.createTracer] - Using OpenTelemetry for tracing
selenium-safari    | 14:21:57.311 INFO [UnboundZmqEventBus.<init>] - Connecting to tcp://GRID-IP:4442 and tcp://GRID-IP:4443
selenium-safari    | 14:21:57.533 INFO [UnboundZmqEventBus.<init>] - Sockets created
selenium-safari    | 14:21:58.542 INFO [UnboundZmqEventBus.<init>] - Event bus ready
selenium-safari    | 14:21:59.275 INFO [NodeServer.createHandlers] - Reporting self as: http://IPMAC:5555
selenium-safari    | 14:21:59.387 INFO [NodeOptions.getSessionFactories] - Detected 4 available processors
selenium-safari    | java.lang.reflect.InvocationTargetException
selenium-safari    |    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
selenium-safari    |    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
selenium-safari    |    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
selenium-safari    |    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
selenium-safari    |    at org.openqa.selenium.grid.Bootstrap.runMain(Bootstrap.java:77)
selenium-safari    |    at org.openqa.selenium.grid.Bootstrap.main(Bootstrap.java:70)
selenium-safari    | Caused by: org.openqa.selenium.grid.config.ConfigException: java.lang.reflect.InvocationTargetException

Thank's for your help

1 Answers

I was getting similar error when tried grid setup without listening to port. Below are few steps by which you can try getting to run it -

  1. Install socat using brew or ports and run the following command in separate terminal socat -4 TCP-LISTEN:2375,fork UNIX-CONNECT:/var/run/docker.sock
  2. Now add following line in your config.toml url=http://host.docker.internal:2375
  3. Now run your docker compose file which will setup node & start listening to port

You might need to look at safaridriver setup. You can follow similar process with Relay as well like we do in case of Appium.

Related