The Basics of Mobile Web Testing on Real Devices Using Appium / Selenium

  January 21, 2015

Many of today’s apps utilize Internet browsers and web technologies, even those native apps on Android and iOS. The effectiveness of testing these apps varies widely among users, which frameworks and tools are used. Majority of teams that are building either solely native, hybrid or web apps use Agile methodology wherein test automation has a significant value to offer.

Today we’ll take a look at how Appium/Selenium can be used to test your mobile web experience running on real environments (real devices and browsers, and not emulators).

Appium and Selenium

First Thing First: Appium equals Selenium

Appium is like Selenium – but for mobile apps and games“. You’ve probably read/heard this several times before, but in fact, Appium is much more than that. Appium is also suitable for mobile web testing when real devices and real browsers are used in testing. Emulators won’t do the trick as e.g. Chrome cannot be even installed on standard Android QEMU-based emulator. Some emulators may work (with Chrome), but why to bother – those are still emulators and no single end-user uses emulators to run your app, game or web products. With the same effort (and cost) you can build your test automation with Appium using the real stuff.

In a nutshell, Appium is a mobile test automation framework (with a tool) that works for all: native, hybrid and mobile web apps for iOS and Android. Appium is a great choice for test automation framework as it can be used for all these different app/web types. Basically, Appium derives its roots from Selenium and it uses JSONWireProtocol internally to interact with iOS and Android apps using Selenium’s WebDriver.

In its architecture, Appium is an HTTP server written in Node.js that creates and handles multiple WebDriver sessions. Appium starts tests on the device and listens for commands from the main Appium server. It is basically the same as the Selenium server that gets HTTP requests from Selenium client libraries.

Appium Behind the scene

Appium has proven its flexibility and scalability in native mobile app and game testing, as those apps and games tend to be pretty much identical on both platforms, Android and iOS. The benefit of having these sort of cross-platform framework helps using the identical script either app/game is running on either platform. The very same applies for the mobile web. Appium scripts run nicely whether you are testing website on Chrome, Firefox, Safari, WebKit-based browser on Android and iOS (where applicable).

Another significant benefit of Appium is that users can write tests using their favorite development tools, environment and programming language, such as Java, Objective-C, JavaScript, PHP, Ruby, Python or C#, among many others.

How to Get Started and What Things to Consider?

Don’t worry about the learning curve. If you are familiar with Selenium, then you’ve got Appium covered: They use the same WebDriver, and DesiredCapabilities is used the same way. There is a great chance your existing Selenium test scripts work as they are with Appium setup. Nevertheless, configuring an application to run on Appium has a lot of similarities to Selenium — for example, those DesiredCapabilities. If you are looking an easy way to learn more about Appium, check out what our friends at CrossBrowserTesting have to say.

Bear in mind that the mobile ecosystem is very different compared to the desktop world. As mobile OEMs are building their own stuff, they also tend to ‘differentiate’ things on various standard things – such as browsers. In fact, mobile browsers – regardless how standard they are – is also one of those areas where almost all devices manufacturers want to add their ‘innovation’ and this is quickly leading to a happy mix of different WebKit versions with different functionalities. That combined with the OS version, hardware configuration, different sizes of displays, memory and so on can significantly ‘differentiate’ what user gets a form of these browsers. Building your test scripts with Appium/Selenium and automating testing can quickly get you understanding how well does your web stuff work on those devices and browsers.

Another area that any mobile web developer needs to pay attention at is performance: Web page rendering time varies significantly from one device to another and to ensure an acceptable end-user experience you need to test how your CSS & Javascript renders across devices. There are already great benchmarks that can be used to measure the performance of hardware together with a certain version of a browser. This gives an understanding of how well certain workload (unfortunately not configurable nor your own web stuff is usable on these browser benchmarks) does on a certain device with a certain web browser. But to understand how your own web stuff behaves under different conditions, test automation with Appium/Selenium has a lot to offer.

Selenium has already cemented its place as a de-facto web test automation standard and Appium is providing very clean high-level API that can be quickly adopted by Selenium developers, as it nicely abstracts a lot of the messy stuff related to running tests. Bitbar Testing provides this sort of environment where everything is packaged and pre-build for your Selenium / Appium tests, using only real mobile devices (Android and iOS) and real browsers that are usable with those devices (Safari for iOS, Chrome, WebKit, Firefox and others for Android).

Example: Appium for Mobile Web Testing

Here is one example of how we’ve enabled Appium with real devices and real browsers, using the Bitbar’s infrastructure to get Selenium-based test scripts up and running on real devices.

Happy Web Testing!