V7.0.7: How to play a sound?

I have this command:

    {
      "Command": "executeScript_Sandbox",
      "Target": "const audio = new Audio(\"https://translate.google.com/translate_tts?ie=UTF-8&tl=en&client=tw-ob&q=Testing+UI+Vision+audio\");\naudio.play();",
      "Value": "",
      "Description": ""
    },

It used to play fine. But now with the V7.0.7, I can’t run this command.
I changed it into executeScript but it still doesn’t work.

What should I do?

Interesting, I confirmed the problem. We will look into it.

If you have more such conversion issues, please post them here and we will check it ASAP.

1 Like

Developments tells us that the challenge with Audio is that the play action has to be triggered by a real user input like clicks. The previous executeScript_Sandbox could work around that previously probably because it’s an extension page instead of a normal page. But manifest V3 blocks this.

Here is a solution for audio replay. The “trick” is to use selectWindow | TAB=OPEN | url to audio

{
  "Name": "audio",
  "CreationDate": "2022-4-26",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://ui.vision",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "selectWindow",
      "Target": "TAB=OPEN",
      "Value": "https://translate.google.com/translate_tts?ie=UTF-8&tl=en&client=tw-ob&q=Testing+UI+Vision+audio",
      "Description": "Play audio in new tab"
    },
    {
      "Command": "selectWindow",
      "Target": "TAB=0",
      "Value": "",
      "Description": "Go back to main tab to continue with the macro"
    },
    {
      "Command": "clickAndWait",
      "Target": "linkText=Enterprise-Grade Security",
      "Value": "",
      "Description": "...this line continues the main macro"
    }
  ]
}
1 Like

how can I close the new tab? @admin

  • selectWindow | TAB=CLOSE

or

  • selectWindow | TAB=CLOSEALLOTHER

See selectWindow, select Window - Selenium IDE Commands Tutorial

1 Like

This works fine:

    {
      "Command": "executeScript",
      "Target": "var audio = new Audio(\"http://codeskulptor-demos.commondatastorage.googleapis.com/descent/gotitem.mp3\");\naudio.play();",
      "Value": "",
      "Description": ""
    }