1

Issue: Audio not working in Chrome when using Selenoid Docker with remote WebDriver

Description: As an automation developer, I am currently facing an issue with audio playback in Chrome when using a remote WebDriver with Selenoid Docker. The automated test scenario involves opening a Zoom meeting using Selenium and waiting for a bot to join the call, which generates audio from a fake audio file. The Zoom meeting is then saved in our system.

The problem occurs when running the test locally on a Mac M1 machine using a remote WebDriver (Selenoid). In the Zoom meeting UI, the audio icon does not turn green, indicating that audio is not functioning properly.

Automated test Scenario
Expected behaviour:

  1. Open Zoom meeting with Selenium
  2. Wait for a Bot to join the call (the Bot is our feature in our product)
  3. Once the Bot has joined the call, we can see the audio icon goes green (implying that there is audio) - The audio is coming from fake audio file
  4. The Zoom meeting is saved to our system

Actual behaviour:

  • Success: When this scenario is run on my local Mac M1, with a local web driver, everything works as expected.
  • Failure: The problem starts when I run the test locally on the Mac M1, but using the Selenoid remote web driver, within the Zoom meeting UI it shows that the audio icon is NOT green.

Additional Information:

  • The automation is implemented in Python using Selenium. The Selenoid server is running on an AWS EC2 Linux machine, which hosts multiple Docker containers.

  • The Selenoid server is listening on ports 4444 and 8080.

  • ALSA and PulseAudio are installed on the EC2 instance, and the PULSE_SERVER environment variable is set to "172.17.0.1" for the Selenoid container.

  • The /etc/pulse/default.pa file on the EC2 instance has been edited to enable the native TCP protocol.

  • The audio file a1.wav is present in the EC2 instance and mounted in the Selenoid container.

  • Running the play /home/ubuntu/a1.wav command in both the EC2 instance and the Selenoid container indicates that the file is playing correctly (although there are no speakers).

  • The audio file path is correctly mapped in the Selenium options for the fake audio capture.

Question:

  • If the file is being played when using play/aplay(sox) inside the selenoid container, why its not played via browser (audio icon is not green, like in local run on local web driver), Assuming the file in the right location in fake-audio options

Below is a sample of the code:

Connect to remote driver

webdriver.Remote(
  desired_capabilities=capabilities,
  command_executor=http://ip of ec2 that run the solenoid:4444//wd/hub
  options=chrome_options,
)

Options:

  chrome_options = Options()
  chrome_options.add_argument("--window-size=1920,1080")
  chrome_options.add_argument("--use-fake-ui-for-media-stream")
  chrome_options.add_argument("--use-fake-device-for-media-stream")
  chrome_options.add_argument("--use-file-for-fake-audio-capture=/home/ubuntu/a1.wav")
  chrome_options.add_argument("--reduce-security-for-testing")
  chrome_options.add_argument("--allow-file-access-from-files")

Capabilities:

  {
    "browserName": "chrome",
    "browserVersion": "114.0",
    "selenoid:options": {"enableVNC": True, "enableVideo": True, "enableAudio": True},
  }

Experimental options

  "profile.default_content_setting_values.media_stream_mic": 2,
  "profile.default_content_setting_values.media_stream_camera": 2,
  "profile.default_content_setting_values.geolocation": 2,
  "profile.default_content_settings.popups": 2,
  "plugins.plugins_disabled": "Chrome PDF Viewer, Adobe Flash Player",
  "credentials_enable_service": "false",
  "profile.password_manager_enabled": "false",
  "download.prompt_for_download": "false",
  "enableNetwork": "true",
  "download.default_directory": str(TEMP_FOLDER_PATH),

Selenoid setup: docker-compose.yml
(Hosted and running on an AWS EC2 instance)

    version: '3'
    services:
      selenoid:
        image: "aerokube/selenoid:latest-release"
        privileged: true
        command: -listen :4444 -conf /home/ubuntu/browsers.json -video-output-dir /home/ubuntu/video -timeout 3m -limit 1
        network_mode: bridge
        ports:
          - "4444:4444"
        volumes:
          - "$PWD:/home/ubuntu/" # assumed current dir contains browsers.json
          - "/var/run/docker.sock:/var/run/docker.sock"
       
    
        environment:
          - PULSE_SERVER=172.17.0.1
            # - PULSE_SERVER=unix:/tmp/pulseaudio.socket  
          - PULSE_COOKIE=/tmp/pulseaudio.cookie  
            #      - OVERRIDE_VIDEO_OUTPUT_DIR=/Users/pawan.gupta/ZoomInfo/video
      selenoid-ui:
        image: "aerokube/selenoid-ui"
        network_mode: bridge
        links:
          - selenoid
        ports:
          - "8080:8080"
        command: [ "--selenoid-uri", "http://selenoid:4444" ]
        environment:
          - PULSE_SERVER=172.17.0.1
        volumes:
          - "$PWD:/home/ubuntu/" # assumed current dir contains browsers.json
            #- "/var/run/docker.sock:/var/run/docker.sock"
      video-recorder:
        image: "selenoid/video-recorder:latest-release"
        network_mode: bridge
        links:
          - selenoid
      chrome-vnc:
        image: "selenoid/vnc:chrome_114.0"
        network_mode: bridge
        links:
          - selenoid
        environment:
          - PULSE_SERVER=172.17.0.1
        volumes:
          - "$PWD:/home/ubuntu/" # assumed current dir contains browsers.json
      
      
    The browsers.json file :
    {
      
      "chrome": {
        "default": "114.0",
        "versions": {
          "114.0": {
            "image": "selenoid/vnc:chrome_114.0",
            "port": "4444",
            "tmpfs": {"/tmp":"size=1024m"}
          }
        }
      }
    
    }

Screenshots illustrating the behaviour:

Run remotely using Selenoid enter image description here

Run locally using WebDriver enter image description here

djmonki
  • 3,020
  • 7
  • 18
ohadshay
  • 225
  • 1
  • 3
  • 16

0 Answers0