How to use Selenium to test websites on real mobile devices

How to use Selenium to test websites on real mobile devices

Introduction

Kobiton is a cloud platform for executing automated and manual mobile and web tests. Kobiton supports running automated tests with Selenium WebDriver (for web applications) and Appium (for native and mobile web applications).

You can test your websites with your favorite language - no need to learn specific scripting languages or learn a new programming language. In addition, you also don't need to install testing SDKs and even the Appium binding can be a pain point for test and dev team. When you run Appium in the cloud, there is no need to install Appium and set up your devices. You'll have access to test on hundreds of browsers instantly.

Today, I’ll walk you through a basic example of how to use Appium / Selenium for mobile cross-browser testing using real Android and iOS devices and real web browsers on these platforms on Kobiton Cloud.

Setting Up Desired Capabilities

If you do not have a Kobiton account yet, go ahead to create a free trial account and sign in. It takes just a few moments.

After signing in, you should be on the Devices page. Hover over the device you want to test and select Show automation settings for Java language as below:

For Android device:

For iOS device:

Capture Screenshots

It allows skipping screenshots for each HTTP command or not. Depending on these screenshots, we can know the error or UI issue during running automation test. Please see the example:

Portrait/Landscape

It's possible to rotate the device before your test and you will have a different view of your website. Please see the example:

Rotate before test:

Creating And Running A Mobile Browser Test

After all these steps have been done, let’s look at how to use WebDriver to get the test running. First, you need to initiate the WebDriver. Note that if you are using client-side execution this really may take some time as the device will be prepared for your session.

Code Sample

This code example illustrates setting up a simple Java test to find the title of Appium page.

For Android device:

For iOS device:

The result displays as below:

No Comments

Post A Comment