This is a guest post by Philipp Hancke. He was kind enough to share the work he’s done already in automating his own WebRTC Safari tests.
Now that Apple added WebRTC to its Safari browser, it is time to ask –
How do you test WebRTC four browsers on different operating systems? Using Selenium Grid it is surprisingly easy, learn how.
Webkit recently joined the WebRTC ship which means we now have 5 major browsers to test:
- Chrome, any operating system
- Firefox, any operating system
- Microsoft Edge, Windows 10
- Safari (Technology Preview), OSX
Until a few days ago it was feasible to run tests all WebRTC supported browsers only on a single operating system (Getting Chrome, Firefox and Edge tested on Windows 10). With Safari, that has changed. Sounds like a big problem, no?
This kind of testing is typically done using Selenium which is used to remotely control the browser. And if it is remotely controlled it can be done with selenium’s grid functionality. Which is surprisingly easy.
Say we want to test Edge and Safari from a Windows machine. First step is to download the selenium standalone jar file. I am still sticking to version 3.3.1. Next, set up a selenium grid hub on one machine by running:
java -jar selenium-server-standalone-3.3.1.jar -role hub
This will start a hub which is where you connect your selenium nodes as well as test clients to. It will also tell you the URL that you need to connect your nodes to.
Next, start a node on your OSX machine by running:
java -jar selenium-server-standalone-3.3.1.jar -role node -hub http://where-your-hub-tells-you-it-is-running -browser "browserName=safari"
This will start a node that will run your Safari instance.
Now, in the code running selenium you need to instruct it to do two things:
Next run your test code. If it works out of the box, great. If it does not you will probably spend a lot of time figuring out the issues. The most common issue here is forgetting to include the respective WebDriver binary in a path where it is found.