Forum Discussion

Colin_McCrae's avatar
Colin_McCrae
Community Hero
11 years ago

Chrome 32 - Audio Indicator?

Hi



You may have noticed that Chrome 32 has introduced an audio indicator in the tab for that page. Any time audio is played by the page open on that tab, you get a little speaker to indicate that its playing audio.



Is there any way TestComplete (I'm running v10) can watch this icon and detect it appearing when audio is played? I can't seem to find any way to identify/get to it ...



Or if there is some other way I can detect audio events within a browser, please let me know. I've not managed to find anything so far. The application/site I'm testing makes a short "beep" when certain events happen, if possible, I would like to detect the "beep" as part of my test pack. Doesn't need to do anything clever like determine what the sound was or anything, so the visual indicator would be fine ...

  • Hi Colin,


     


    I performed some investigation. It turned out that the value of the Description property of the target tab is changed when the music is playing on it. This tab is playing audio is added to the end of the tab title. You can check it in the Object Browser. So, you can use the script below to identify whether the music is playing on the specified tab:


     




    //JScript


    function TestAudioIndicatorInChrome()


    {


     // change <TAB TITLE> in the line below 


      var tabObj = Sys.Browser("chrome").BrowserWindow(0).Client("Google Chrome").

         Client(1).Client(0).TabList(0).PageTab("<TAB TITLE>");


      var tabTitle = tabObj.Description;


      var strPlay = "This tab is playing audio";


      var Res = aqString.Find(tabTitle, strPlay);


      if ( Res != -1 ) 


        Log.Message("The music is playing")


      else


        Log.Message("The music isn't playing")


    }




     


     


    How does it work for you?

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Colin,


     


    I performed some investigation. It turned out that the value of the Description property of the target tab is changed when the music is playing on it. This tab is playing audio is added to the end of the tab title. You can check it in the Object Browser. So, you can use the script below to identify whether the music is playing on the specified tab:


     




    //JScript


    function TestAudioIndicatorInChrome()


    {


     // change <TAB TITLE> in the line below 


      var tabObj = Sys.Browser("chrome").BrowserWindow(0).Client("Google Chrome").

         Client(1).Client(0).TabList(0).PageTab("<TAB TITLE>");


      var tabTitle = tabObj.Description;


      var strPlay = "This tab is playing audio";


      var Res = aqString.Find(tabTitle, strPlay);


      if ( Res != -1 ) 


        Log.Message("The music is playing")


      else


        Log.Message("The music isn't playing")


    }




     


     


    How does it work for you?

  • No problem.



    It's much the same as your JScript version really. It was just knowing where the object was. If I'd added Chrome to my MSAA settings, I would have figured it out without asking. None of the child items show up below BrowserWindow(0) until you do this. As soon as you do, it all becomes clear.



    Anyway, just to prove it works, I used:




    Set tabObj = Sys.Browser("chrome").BrowserWindow(0).Client("Google Chrome").Client(1).Client(0).TabList(0).PageTab("<TAB NAME>")



    x = tabObj.Description



    chk = instr(x, "This tab is playing audio")



    ... and then if "chk" returns a value greater than zero, you detected audio.



    Very handy. The drawback obviously being that it creates a load more work for me as I can now automate all the beep tests!


  • Hi Tanya



    Thanks for the reply.



    I got it working (in VBScript - I should have mentioned that). But there was a little missing info.



    I had to addd "Chrome_WidgetWin_1" (Chrome's window class name) to my Project Properties > Open Applications > MSAA.



    Before doing that, it didn't work.



    Got the info around adding it's window class here:



    http://support.smartbear.com/viewarticle/51660



    I'm guessing you had probably already done this at some point so it just worked for you.



    Thanks again. :)
  • Just to add a little more to this .....



    I wrote a module which detects audio using the description field. And with a single browser instance, it works fine.



    But I wanted to monitor up to four browser instances (each with a different URL open) at one. Identifying each browser, and the tab within it I want to monitor is fine. No problems there. But the description field does not get populated for all browsers when more than one is open. I have no idea why. Maybe by design, but I suspect it's more likely a bug with Chrome. This is new functionality with Chrome 32 so it's perfectly possible it isn't quite 100% yet.



    With four browsers open, only one of them returns info from the description field. Nothing I do will cause it to re-appear in the other three. Moving them into focus, doing something on screen, refreshing ..... tried it all. Nothing worked. Only one browser ever gave me back anything from the description field. Same in the object browser in TC. All blank except one.



    So, to sum up:



    The above works. But only with one browser instance.
  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Colin,


     


    Thanks for your comment. Definitely, the class name must be added to the MSAA settings.


    Can you share your VBScript here? Perhaps, it may help someone else. 


     

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Colin,


     


    A strange thing is that I can see This tab is playing audio in two and more opened Chrome windows.


    Perhaps, the web site that plays music affects this somehow...