Back to Resources


Posted February 4, 2023

Can Selenium Be Used for Mobile Testing?

If you love Selenium, you can get a Selenium-like testing experience for mobile apps by taking advantage of Appium and Selendroid.


This blog post was first published in 2016 and has been updated with the latest information.

Can Selenium be used for mobile testing?

While Selenium was not designed for mobile testing, and can't be used to test mobile apps directly, Selenium-based frameworks – such as Appium and Selendroid – do allow you to test mobile apps using an approach very similar to traditional Selenium testing.

Keep reading for a look at how these frameworks work and how they extend Selenium into the world of mobile apps.

Selenium Wasn't Designed for Mobile Testing

Before looking at how to use Appium and Selendroid for Selenium-based mobile testing, let's talk about why Selenium itself doesn't support mobile testing.

It's not because of any inherent flaw or limitations in Selenium. It's because mobile testing is fundamentally different from conventional browser testing in many ways, including:

  • Device types: There are thousands of different types of mobile devices in the world, and being able to test across them – often with the help of emulators and simulators

    – is important for mobile testing. Hardware differences are less important on conventional browser apps.

  • Gestures: Mobile apps can accept input based on gestures like swiping. Conventional browser apps don't support gestures.

  • Buttons: Mobile devices have special hardware buttons that don't exist on a PC. You may need to test input from those buttons as part of your mobile app testing workflow.

  • Screen rotation: Mobile apps may need to respond to screen rotations, which traditional browser apps never do.

In these ways and more, mobile apps have unique testing requirements that don't apply to conventional browser-based apps. And because Selenium was designed only for conventional browser apps, it can't meet the special needs of mobile apps.

Theoretically, Selenium developers could have tried to build support for mobile apps into the Selenium framework. But then they would have ended up with a testing framework that tried to do too many different things. As the Unix philosophy states, it's better to do one thing and do it well than to do many things and do them poorly. Selenium focuses on testing for conventional apps, leaving it to other frameworks to handle mobile testing.

Selendroid and Appium

But just because Selenium itself doesn't support mobile testing doesn't mean developers can't create frameworks on top of Selenium that do extend to mobile.

That's precisely what Selendroid and Appium are. They both let you use tests using a variety of languages – like C#, Python, and Java – and then execute them using an architecture similar to the WebDriver protocol. They also both support the testing of browser-based, native, and hybrid apps across both Android and iOS devices (although, as we explain below, Selendroid is not ideal for iOS testing).

For example, here's the code you might write to set up a driver instance for testing an Android app:

driver = new AndroidDriver<>(new URL(""), desiredCaps);

We can then use this driver instance to interact with elements in the app under test. For example, we can find an element by its ID and click on it:


Similarly, we can find an element by its XPath and enter some text into it:

driver.findElement(By.xpath("//android.widget.EditText[@resource-id='com.example.myapp:id/editText1']")).sendKeys("Hello, world!");

Choosing Between Appium and Selendroid

At this point, you may be wondering, "If Appium and Selendroid both make it possible to run Selenium-like tests on mobile devices, which framework should I choose?"

The answer is that, in general, Appium is the better choice if you want a Selenium-like approach to mobile testing. Appium is more popular overall, it is better supported, and it supports a wider range of test cases. It can test iOS apps without any special configurations (Selendroid requires a special iOS driver for iOS testing), plus Appium can test Windows desktop apps natively – which comes in handy if you need to test cross-platform apps and want a single framework to do it.

That said, the main reason why you might choose Selendroid in some cases is that it offers better backwards-compatibility support. Selendroid supports Android versions 2.3.3 through Android 4.4, whereas modern versions of Appium support only Android 4.3 and up.

For more details on the differences between Appium and Selendroid – and what to use when – check out our Selenium vs. Appium blog post.

Conclusion: Yes, You Can Test Mobile Apps with Selenium (Sort of)

In short, Selenium itself doesn't support mobile app testing. But if you love Selenium, you can get a Selenium-like testing experience for mobile apps easily enough by taking advantage of Appium and Selendroid. In certain cases, you can even test desktop apps with Appium – although Selenium is a better choice if you have extensive desktop testing needs.

Sign up for a free Sauce Labs trial and experience the benefits of Sauce Labs mobile app testing.

Feb 4, 2023
Share this post
Copy Share Link
© 2023 Sauce Labs Inc., all rights reserved. SAUCE and SAUCE LABS are registered trademarks owned by Sauce Labs Inc. in the United States, EU, and may be registered in other jurisdictions.