xcui Archives - Automated Visual Testing | Applitools https://applitools.com/blog/tag/xcui/ Applitools delivers the next generation of test automation powered by AI assisted computer vision technology known as Visual AI. Mon, 06 Dec 2021 19:42:12 +0000 en-US hourly 1 Appium vs Espresso vs XCUITest – Understanding how Appium Compares to Espresso & XCUITest https://applitools.com/blog/appium-vs-espresso-vs-xcui/ Fri, 12 Mar 2021 02:06:42 +0000 https://applitools.com/?p=27600 In this article we shall look at the Appium, Espresso and XCUITest test automation frameworks. We’ll learn the key differences between them, as well as when and why you should use...

The post Appium vs Espresso vs XCUITest – Understanding how Appium Compares to Espresso & XCUITest appeared first on Automated Visual Testing | Applitools.

]]>

In this article we shall look at the Appium, Espresso and XCUITest test automation frameworks. We’ll learn the key differences between them, as well as when and why you should use them in your own testing environment.

What is Appium

Appium is an open source test automation framework which is completely maintained by the community. Appium can automate Native, Hybrid, mWeb, Mac Apps and Windows Apps. Appium follows the Selenium W3C protocol which enables the use of the same test code for both Android and iOS applications.

Under the hood Appium uses Espresso or UIAutomator2 as the mode of communication to Android Apps and XCUI for iOS. In a nutshell, Appium provides a stable webdriver interface on top of automation backends provided by Google and Apple.

Installing Appium was a bit of hassle for a long time, hence from Appium 2.0 architecturally we could choose to install the drivers and plugins as we wanted. You can find more details about Appium 2.0 here.

Highlights of Appium

  • When Espresso or XCUI upgrades the API contract, Appium under the hood will make necessary changes and the test will remain unchanged and work as before.
  • supports Cross platform testing, i.e., write one test that runs across many platforms.
  • allows users to write tests in WebDriver compatible languages – Java, Python, C#, Ruby, JS, etc.
  • Does not require application to be recompiled as it uses standard automation APIs across all platforms.
  • A Black box testing tool which also supports Gray box testing to some extent with Espresso’s driver backdoor capability.
  • Can switch between Espresso driver and UIAutomator2 driver for Android in a single session. (For example: Creating a session with Espresso Driver and then we can move to UIAutomator2 to perform actions outside of application under test.)
View the code on Gist.
  • The latest Webdriver W3C Actions API is designed in such a way that any complex gestures can be designed and executed on any platform, e.g., Android, iOS. Below is an example of a swipe gesture that runs on Android and iOS platforms.
View the code on Gist.
View the code on Gist.
  • Appium has a locator strategy specific to Espresso, e.g., Data Matcher strategy, and another for XCUI, e.g., NSPredicates and ClassChain
View the code on Gist.

What is Espresso

Espresso is an Android test framework developed by Google for UI testing. Espresso automatically synchronizes test actions with the user interface of the mobile app and ensures that activity is started well before the actual test run.

Highlights of Espresso

  • Feedback cycle is fast as it doesn’t require server communication. 
  • Allows users to create custom view matchers and is based on Hamcrest matchers.
  • Espresso Framework can be categorized between black box and white box testing, commonly called as gray box testing framework.
  • Accessibility testing is possible in Native Espresso.
  • Requires the entire code base to run the test.
  • Locator strategy is Id from R file.
  • Applitools Ultrafast Grid can be used to perform visual testing.
  • For testing webviews, Espresso internally uses WebDriver APIs to control the behaviour of a webview.
View the code on Gist.

What is XCUITest

The XCUITest framework from Apple helps users write UI tests straight inside the Xcode with the separate UI testing target in the app.

XCUITest uses accessibility identifiers to interact with the main iOS app. XCUITests can be written in Swift or Objective-C. 

There isn’t a reliable framework out there which easily supports testing on Apple TV devices. XCUITest is the only way to verify tvOS apps. SinceXcode 7, Apple has shipped XCTest prebuilt into its development kit. 

Highlights of XCUITest

  • Runs in a separate process from our main iOS app and it doesn’t access an application’s internal methods.
  • XCUIElement class in XCUITest provides gestures such as tap, press, swipe, pinch and rotate.
View the code on Gist.
  • Offers several inbuilt assertions e.g., XCTKVOExpectation, XCTNSNotificationExpectation, XCTDarwinNotificationExpectation, XCTNSPredicateExpectation, etc.
View the code on Gist.

Conclusion

Appium, Espresso and XCUI can each fill different needs for UI testing. The way to choose between them is to consider the requirements of your project. If your scope is limited just to one platform and you want comprehensive and embedded UI testing, XCUI or Espresso are great fits. For cross-platform testing across iOS, Android, and Hybrid then Appium is your best choice. 

The post Appium vs Espresso vs XCUITest – Understanding how Appium Compares to Espresso & XCUITest appeared first on Automated Visual Testing | Applitools.

]]>
Getting Started with Appium 2.0 Beta https://applitools.com/blog/appium-2-0-beta/ Tue, 09 Feb 2021 23:47:06 +0000 https://applitools.com/?p=26748 Appium team has released 2.0.0-beta.10 recently with the official Appium image plugin and some minor bug fixes and improvements over its earlier beta versions.

The post Getting Started with Appium 2.0 Beta appeared first on Automated Visual Testing | Applitools.

]]>

Appium released its first major version almost 7 years ago. Since then, Appium has rolled out a lot of new features and its automation backend architecture has evolved quite a lot. 

Appium 2.0, the next major release, has been in talks for a couple of years now, as Jonathan Lipps and the team have been brainstorming and implementing new features. 

Installing Appium 2.0 Server

Appium team has released 2.0.0-beta.10 recently with the official Appium image plugin and some minor bug fixes and improvements over its earlier beta versions. Appium 2.0 beta versions can be installed using the below command:

npm install -g appium@next 

Appium server can take up several optional arguments. In addition to the server arguments, Appium 2.0 introduces new arguments:

  • -ah to specify a directory to install Appium drivers
appium server -ah /path/to/install/drivers driver install uiautomator2
  • -ka or –keep-alive-timeout to specify the number of seconds the Appium server should apply as both the keep-alive timeout and the connection timeout for all requests. Defaults to 600 seconds.

appium server -ka 800

Decoupled Drivers

Appium drivers (UIAutomator2 driver, XCUITest driver, Espresso Driver, etc) are tightly coupled with Appium Server but from Appium 2.0 these drivers are separated from Appium Server and can be installed separately based on users’ needs. Creating custom drivers for any new platform or special use cases are going to be easy from Appium 2.0. 

For example, in the future, we might have an Appium Wear driver to automate WearOS Apps or an Appium KaiOS driver to automate smart feature apps in kaiOS.

To list all the available drivers in appium, enter the following command:

appium driver list
✔ Listing available drivers
- uiautomator2 [not installed]
- xcuitest [not installed]
- youiengine [not installed]
- windows [not installed]
- mac [not installed]
- mac2 [not installed]
- espresso [not installed]
- tizen [not installed]
- flutter [not installed]
- safari [not installed]
- gecko [not installed]

To install a driver for say uiautomator2 driver, Appium now has subcommands to install, update, etc

appium driver install uiautomator2
Attempting to find and install driver 'uiautomator2'
✔ Installing 'uiautomator2' using NPM install spec 
'appium-uiautomator2-driver'
Driver uiautomator2@1.61.2 successfully installed
- automationName: UiAutomator2
- platformNames: ["Android"]

To view the list of installed appium drivers, type the following command:

appium driver list --installed
✔ Listing installed drivers
- uiautomator2@1.61.2 [installed (NPM)]

There are many other options offered by the Drivers CLI to install drivers from a specific source, update all the installed drivers, etc. This simplifies the overall installation process and users have the flexibility to choose to upgrade drivers without updating the server itself.

Plugins

Appium plugins will be here to help with the various use cases that require a change to Appium’s default behavior. These changes provide users an opportunity to build new plugins in the future, for example,  Jonathan Lipps is currently working on a driver for Roku smart TV!

The Appium team continues to maintain some plugins which can be found here

Plugins help add arbitrary functionality before or after actual Appium commands. Also, the plugin can modify the Appium Server itself to introduce new commands and distribute them. For example, the current “image” plugin from Appium helps find an element by an image and also helps in image comparison too. 

To list all available Appium Plugins:

appium plugin list
✔ Listing available plugins
- images [not installed]

To install an Appium plugin, use this command and replace “images” with the name of the plugin you’d like to install:

appium plugin install images

To activate a plugin when starting the Appium server, use the following command (replace “images” with the name of the plugin you’d like to activate):

appium server -ka 800 --plugins=images -pa /wd/hub
[Appium] Welcome to Appium v2.0.0-beta.10
[Appium] Non-default server args:
[Appium]   plugins: {
[Appium]     0: images
[Appium]   }
[Appium]   basePath: /wd/hub
[Appium]   keepAliveTimeout: 800
[Appium]   tmpDir: 
/var/folders/f5/fwh8w_ms6q377gn_fb2bmjp40000gp/T
[Appium] Appium REST http interface listener started on 
0.0.0.0:4723
[Appium] Available drivers:
[Appium]   - uiautomator2@1.61.2 (automationName 
'UiAutomator2')
[Appium]   - xcuitest@3.36.0 (automationName 'XCUITest')
[Appium] Available plugins:
[Appium]   - images@1.1.2 (ACTIVE)

No code changes are required at this time in the client script to execute using the latest Appium server.

Other Breaking Changes

The minimum node version required for the Appium server to run is node 12.

Summary

A lot of new plugins are expected to come soon. The ability to easily create new drivers and plugins in Appium 2.0 will help solve many interesting use cases and problems that were hard to solve before. Watch this space as we share more details related to the same as it happens. 

Credits to Jonathan Lipps, Mykola Mokhnach, kazucocoa, and other contributors for their wonderful contributions to the Appium community.  

Srinivasan Sekar – https://www.linkedin.com/in/srinivasan-sekar/

Sai Krishna – https://www.linkedin.com/in/sai-krishna-3755407b/

The post Getting Started with Appium 2.0 Beta appeared first on Automated Visual Testing | Applitools.

]]>