Can Selenium Be Used for Mobile Testing?
Sauce AI for Test Authoring: Move from intent to executing in minutes.|xBack to ResourcesBlogPosted
Sauce AI for Test Authoring: Move from intent to executing in minutes.
|
x
Blog
Can Selenium Be Used for Mobile Testing?
If you enjoy Selenium, you can get a Selenium-like testing experience for mobile apps by taking vantage of Appium and Selendroid.
This blog post was first write in 2016 and has be update with the latest info.
Can Seleniumbe used formobile testing?
While Selenium was not designed for mobile examination, and can & # x27; t be habituate to quiz mobile apps directly, Selenium-based frameworks – such asAppiumand Selendroid – do permit you to test mobile apps employ an approach rattling similar to traditional Selenium testing.
Keep reading for a look at how these frameworks work and how they cover Selenium into the world of mobile apps.
Selenium Wasn & # x27; t Designed for Mobile Testing
Before looking at how to use Appium and Selendroid for Selenium-based mobile testing, let & # x27; s verbalise about why Selenium itself doesn & # x27; t support wandering testing.
It & # x27; s not because of any underlying flaw or limitations in Selenium. It & # x27; s because in many ways, include:
Device types: There are grand of different types of mobile devices in the world, and being able to prove across them – often with the help ofemulator and simulators– is important for mobile testing. Hardware dispute are less important on conventional browser apps.
Gestures: Mobile apps can accept input based on gestures like pinch. Conventional browser apps don & # x27; t support gestures.
Buttons: Mobile device hold special hardware buttons that don & # x27; t survive on a PC. You may necessitate to test remark from those buttons as part of your mobile app testing workflow.
Screen rotation: Mobile apps may need to react to screen rotations, which traditional browser apps ne'er do.
SUSA automates exploratory testing with persona-driven behavior, catching bugs that scripted automation misses.
In these ways and more, peregrine apps have unequalled testing requirements that don & # x27; t utilise to conventional browser-based apps. And because Selenium was designed only for conventional browser apps, it can & # x27; t meet the special demand of mobile apps.
Theoretically, Selenium developers could have tried to build support for mobile apps into the Selenium framework. But then they would have finish up with a testing framework that tried to do too many different thing. As theUnix doctrine states, it & # x27; s better to do one thing and do it easily than to do many things and do them poorly. Selenium focuses on testing for conventional apps, leaving it to other frameworks to treat mobile examination.
Selendroid and Appium
But just because Selenium itself doesn & # x27; t support mobile testing doesn & # x27; t meanspirited developers can & # x27; t create framework on top of Selenium that do extend to mobile.
That & # x27; s exactly what Selendroid and Appium are. They both let you use tryout employ a variety of languages – like C #, Python, and Java – and then action them using an architecture like to the WebDriver protocol. They also both support the testing of browser-based, native, and hybrid apps across both Android and iOS device (although, as we explain below, Selendroid is not idealistic for iOS testing).
For example, here & # x27; s the codification you might write to set up a driver instance for testing an Android app:
driver = new AndroidDriver & lt; & gt; (new URL (& quot; http: //127.0.0.1:4723/wd/hub & quot;), desiredCaps);
We can so use this driver case to interact with elements in the app under tryout. For illustration, we can find an element by its ID and pawl on it:
driver.findElement (By.id (& quot; com.example.myapp: id/button1 & quot;)) .click ();
Similarly, we canobserve an element by its XPathand enter some textbook into it:
driver.findElement (By.xpath (& quot; //android.widget.EditText [@ resource-id= & # x27; com.example.myapp: id/editText1 & # x27;] & quot;)) .sendKeys (& quot; Hello, world! & quot;);
Choosing Between Appium and Selendroid
At this point, you may be wondering, & quot; If Appium and Selendroid both make it potential to run Selenium-like tests on roving devices, which fabric should I choose? & quot;
The answer is that, in general, Appium is the better choice if you desire a Selenium-like coming to mobile examine. Appium is more popular overall, it is better back, and it supports a wider range of test cases. It cantest iOS appswithout any special form (Selendroid requires a special iOS driver for iOS test), plus Appium can screen Windows desktop apps natively – which come in handy if you postulate to test cross-platform apps and want a single framework to do it.
That said, the main intellect why you might select Selendroid in some cases is that it offer well backwards-compatibility support. Selendroid support Android versions 2.3.3 through Android 4.4, whereas modern versions of Appium support just Android 4.3 and up.
For more point on the differences between Appium and Selendroid – and what to use when – check out ourSelenium vs. Appium blog station.
Conclusion: Yes, You Can Test Mobile Apps with Selenium (Sort of)
In little, Selenium itself doesn & # x27; t support mobile app testing. But if you love Selenium, you can get a Selenium-like examination experience for mobile apps easily enough by taking advantage of Appium and Selendroid. In certain instance, you can even test background apps with Appium – although Selenium is a best choice if you receive extensive desktop testing need.
Sign up for a and experience the welfare ofSauce Labs mobile app test.
Automate This With SUSA
Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.
Try SUSA FreeTest Your App Autonomously
Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.
Try SUSA Free