Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Share On Stumbleupon
Contact us
Hide Buttons

Getting started with automation testing for webrtc applications

WebRTC is a free, open project that pro­vides browsers and mobile appli­ca­tions with Real-Time Com­mu­ni­ca­tions (RTC) capa­bil­i­ties via sim­ple APIs.

Automat­ing WebRTC appli­ca­tion brings unique sets of chal­lenges. Most of the times, it requires to have mul­ti­ple clients ( either browser, mobile, desk­top ) open at the same time and doing con­text switch­ing between those. Because you want to do a cer­tain action on one client and ver­ify that other WebRTC client received that action. For exam­ple, in a video chat appli­ca­tion imple­mented using webRTC, you want to ver­ify when a client one shares his video feed, the sec­ond client receives the video feed. Here, I will talk specif­i­cally about open­ing mul­ti­ple chrome browser win­dows and doing con­text switch­ing between those.

Actions to automate

  • open­ing mul­ti­ple browser windows
  • switch­ing to browser win­dow for client one then shar­ing the video feed
  • switch­ing to browser win­dow for client two then check­ing the video feed did appear

Sounds ambi­tious but actu­ally it’s sim­ple. You can achieve it by using nightwatch.js. The key here is when you open a new win­dow you need to set its name. In future, you can switch to that win­dow by spec­i­fy­ing the name of that win­dow in .switchWindow().

Open mul­ti­ple windows

To open a new win­dow and set its name you can use the fol­low­ing snip­pet of code.

  • .execute func­tion takes call­back which is invoked imme­di­ately with argu­ments [URL1, WINDOW1].

  • opens the url in a new win­dow with spec­i­fied prop­er­ties and sets the win­dow name to window1.

To open another win­dow, you can use the same code and pass dif­fer­ent argu­ments. It’s that simple!

In fact, you can open as many win­dows as you want and do con­text switch­ing between those.

Con­text switch­ing between muti­ple windows

Now, in your test suite you can con­text switch between win­dows by using .switchWindow(). For exam­ple, if you want to share a video feed in window1 and make sure it appear in window2, you can do the following:

What can you achieve with this?

You can archi­tect an entire API of your page objects and test suite which does con­text switch­ing between win­dows based on the received win­dow name.

Hence, when­ever you call those API you need to pass the con­text of that win­dow. So, you do not need record sim­i­lar actions for indi­vid­ual win­dows. Are you ready to cre­ate more flex­i­ble API which re-architect your test suite?

You may also like...

  • Edon Sop­jani

    Hi, i try to make call between to users, but when i open my first win­dow and login to it, then i open the sec­ond win­dow and go to login page it logs me as the first user, how can i open new win­dow as new Session?

    • tuto­ri­al­hori­zon

      That is true. You can use the fol­low­ing approach to mit­i­gate this issue:

      After nav­i­gat­ing to the sec­ond user and before login — clear the local­Stor­age, cook­ies, ses­sion­Stor­age, ser­vice­Work­ers and any other stor­age which your appli­ca­tion uses. Then you will be able to login as user 2 in the sec­ond win­dow. I hope it helps.