Testing Mobile Web Apps Using Appium
We shall now be understanding the process of testing mobile web app using Appium, But before that lets take a look at the types of mobile web apps.
Many people associate Appium with native mobile apps. Such that it still remains Appium’s core value proposition. However, Appium allows you to test a variety of apps – not just native.
Primarily, there are three kinds of mobile apps –
- Native apps – These are apps which are written and built using the OS-provided SDK and native APIs.
- Web apps – These are apps which are written in HTML/JS/CSS and deployed via a web server.
- Hybrid apps. These are apps which mix the previous two modes into the same app. Hybrid apps have a native “shell”, which might involve a fair amount of native UI, or it might involve no native UI at all.
Further, Appium allows you to automate any kind of app, across both iOS and Android platforms. Also, the only distinction is in how you set up the desired capabilities, and then in the commands you have access to once the session is started. Note, an Appium-based mobile web test is just the same thing as a Selenium test. In general, you can even use a standard Selenium client to speak to the Appium server and automate a mobile web app. The key is to use the browserName capability instead of the app capability.
Remember, for testing mobile apps there is no difference between platforms in how your test is written. Similarly, you would expect the code for your Selenium tests to remain the same, irrespective whether you are testing Firefox or Chrome.
We will now use the capabilities to start a session on these two mobile browsers –
Test Safari on iOS
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“platformName”, “iOS”);
capabilities.setCapability(“platformVersion”, “11.2”);
capabilities.setCapability(“deviceName”, “iPhone 7”);
capabilities.setCapability(“browserName”, “Safari”);
Test Chrome on Android
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“platformName”, “Android”);
capabilities.setCapability(“deviceName”, “Android Emulator”);
capabilities.setCapability(“browserName”, “Chrome”);