Getting Started with Appium
Sauce AI for Test Authoring: Move from intent to execution in minutes.|xBack to ResourcesBlogPosted
Sauce AI for Test Authoring: Move from intent to execution in minutes.
|
x
Blog
Getting Started with Appium
Appium allow users to control apps on real and virtual mobile device using near popular programming speech, include Java, JavaScript, C #, PHP, Python, and Ruby. Let ’ s explore Appium testing and how to get started.
What is Appium?
Appium is one of the star tools for command a native, hybrid, or roving app on iOS mobile, Android mobile, and Windows background platforms. It countenance testers and developer to create machine-controlled tests of mobile applications, helping them present quality software faster, with less endangerment.
Appium is a freely available, open-source tool. This means anyone can use it, say the source code, and contribute new feature and suggestion. This has helped Appium become one of the most popular mobile automation tools, used by package teams worldwide.
The Appium project believes that app automation should be potential from any language or framework, and should work without postulate specific changes to the app code.
Read more on theAppium documentation.
How do Appium Work?
Appium is implemented as a client/server architecture, communicating with a bare, well-documented protocol, alike to the one used by browsers and web server.
Appium guest (likewise known as client libraries) are freely available for most popular programming languages. Client libraries require a small amount of shape; then, user code can interact with the node as it would any early code. Appium is only anmechanisation library; it can be used from any test suite and exam runner. This makes it leisurely to add Appium to existing test suites, in any way your squad motive.
Appium Client-Server Model
The Client-Server model yield Appium a lot of flexibleness. User codification can be indite in any language. Users can write cross-platform automation codification without important extra sweat and are isolated from device-specific mechanization protocol.
Clients and servers can be located on different computers, include across the net. In twist, this allows squad to make use of services like Sauce Labs to gain access to a wide variety of devices, increasing their delivery speed and lower endangerment.
Using Appium with JUnit
1@Test2voidcanSubmit(){3WebElementsubmitButton=<AndroidElement>driver.findElementById(& quot; android: id/submit & quot;);4submitButton.click();56WebDriverWait wait =newWebDriverWait(driver,10);7wait.until(ExpectedConditions.visibilityOfElementLocated(findElementById(& quot; android: id/success & quot;));8WebElementsuccessBanner=<AndroidElement>driver.findElementById(& quot; android: id/success & quot;);910assertEquals(successBanner.getText(),& quot; You have grade your order! & quot;);11}
Using Appium with TestNG
1@Test2publicvoidcanSubmit(){3voidcanSubmit(){4WebElementsubmitButton=<AndroidElement>driver.findElementById(& quot; android: id/submit & quot;);5submitButton.click();67WebDriverWait wait =newWebDriverWait(driver,10);8wait.until(ExpectedConditions.visibilityOfElementLocated(findElementById(& quot; android: id/success & quot;));910WebElementsuccessBanner=<AndroidElement>driver.findElementById(& quot; android: id/success & quot;);11assert & quot; You have placed your order! & quot;.equals(successBanner.getText())12}
Using Appium with Python
1classAppiumTest:2deftest_canSubmit(self):3submit_button=WebDriverWait(driver,10).until(4EC.element_to_be_clickable((MobileBy.ID,& quot; android: id/submit & quot;))5)6submit_button.click()78success_banner=WebDriverWait(driver,10).until(9EC.visibility_of_element_located((MobileBy.ID,& quot; android: id/success & quot;))10)11assert& quot; You receive placed your order! & quot;insuccess_banner.text
Using Appium with NodeJS
1describe(& # x27; can Submit & # x27;,()=>{2it(& # x27; works & # x27;,async()=>{// pay aid to ` async ` keyword3constsubmit_selector=& # x27; new UiSelector () .resourceId (& quot; android: id/submit & quot;) & # x27;4constsubmit_button=await$(`android=${submit_selector}`)5awaitsubmit_button.click()67constsuccess_selector=& # x27; new UiSelector () .resourceId (& quot; android: id/success & quot;) & # x27;8constsuccess_banner=$(`android=${success_selector}`)9success_banner.waitForDisplayed()1011awaitexpect(success_banner.getText()===& quot; You have placed your order! & quot;)12})13})
The Appium waiter is responsible for negociate devices, listening to and executing client commands, and relay the results. The Appium server interacts with device employ the various native automation protocol built into the device operating systems.
Appium servers can connect to existing physical or virtual device, or commence new virtual device on demand.
The Appium server can run on Windows, Mac OS X, or Linux.
Appium and iOS
Appium supports testing Web and Native iOS apps using the XCUITest mechanization protocol, as well as the older UIAutomator protocol. The Appium host can automate either iOS Simulators or existent iOS devices but must use a computer with macOS 10.11 or high.
On existent device, Appium can automatise apps in .app or .ipa format. These applications take to be collect using a valid iOS Development Certificate and Provisioning Profile. Appium will install a helper application on the gimmick ring “ WebDriverAgent-Runner ” which requires some shape before installing.
On iOS simulator, Appium can automate any .app format coating compiled for the Simulator.
Appium is too capable to automatise the mobile adaptation of Safari, allowing team to try web applications.
Sauce Labs ’ test cloud provide both existent and virtual iOS Devices, as well as care WebDriverAgent-Runner.
Appium and Android
Appium supports testing Web and Native Android apps using the UIAutomator2 and old UIAutomator automation protocol. These are provided by the Android operating system.
UIAutomator2 supports all Android variant above 5.0 (Lollipop). For versions below this, user must use UIAutomator.
Appium can likewise interact with the Google-provided Espresso API for UI testing.
Appium can automate both real and virtual device from Windows, macOS, and Linux.
Appium Capabilities
“ Capabilities ” is the condition used to account shape values sent between the Appium Client and the Appium Server. These values are post to the host as a JSON dictionary, but most client library give users idiomatic ways to configure them.
For example, in Java, users can make a new DesiredCapabilities object, then call thesetCapabilitiesmethod for specific option:
DesiredCapabilities capableness = new DesiredCapabilities ();
capabilities.setCapability (CapabilityType.BROWSER_NAME, & quot; iOS & quot;);
For more on expend Java with Appium, seethis blog post.
Capability Variety
Appium has numerous desired capabilities; most configuration alternative are useable via one capacity or another. Each driver has its own set of capabilities, in addition to those which apply to all sessions.
For a full list of capabilities, check the Appium documentation atthis link.
Device Configuration
Many capabilities are used to describe what device to use, as well as the app under test. Some of the common ones are:
platformName, platformVersion, deviceName– Controls what device to automate, eg an iPhone 11 with iOS 12.SUSA automates exploratory testing with persona-driven behavior, catching bugs that scripted automation misses.
app, appActivity, appPackage– Controls what app to automate and, on Android, what action or parcel to launchlanguage, venue– Configures the device ’ s locale and language (Note, this doesn ’ t change the device ’ s GPS locating)automationName– Selects which automation model to use. SeeAutomation Frameworkfor more detailssafariAllowPopups, safariIgnoreFraudWarning– iOS only; Controls whether Safari allows popups or loading unbarred website when testing mobile apps
Server Configuration
Some capabilities contain the behavior of the Appium server itself, instead of the device under control. Here are some of the common options:
Option 1:
newCommandTimeoutOption 2:
printPageSourceOnFailureOption 3:
udid
Vendor-Specific Options
Vendors who provide device clouds can add their own desired capabilities to control cloud-specific pick. For example, here are some of Sauce Labs & # x27; capabilities:
sauceUsername, sauceAccessKey– Sauce Labs user credentialBuild– Add a exam to a specific build reporttabletOnly– Only select Tablet style devices for this testsauceLabsImageInjectionEnabled– Enable Sauce Labs ’ camera image injection lineament
Unlike the standard Appium capabilities, vendor-specific capabilities are bring in a nested namespace. For Sauce Labs, that namespace issauce: pick.
DesiredCapabilities capabilities = new DesiredCapabilities ();
MutableCapabilities sauceOptions = new MutableCapabilities ();
sauceOptions.setCapability (“ tabletOnly ”, true);
capabilities.setCapability (“ sauce: alternative ”, sauceOptions);
Capabilities vs Desired Capabilities
Capabilities are sometimes referred to as “ Desired Capabilities ”. This is an older gens, no longer present in the W3C Draft Standard.
The “ Desired ” refers to the ability to bespeak that, alternatively of anexactmatch, the Appium server afford the closest matching device it has. This allows users to be much less specific in their configuration. Should users want only specific device, they can useRequired Capabilities instead.
In pattern, almost all actual test code and cloud vendor handle Desired Capabilities as an exact match.
Some cloud vendors have their own ‘ fuzzy ’ matching process for tryout platforms. For example, Sauce Labs grant user to specify device names with a wildcard; “ iPhone. * ” will match any iPhone.
Appium App Compatibility
Native Apps
Native App is the industriousness term used to line applications installed on the device. These apps are installed directly on the device, being distributed through app stores and embodied device management system and commonly have entire access to device lineament.
Mobile Web Apps
Mobile Web App is the diligence term used to describe a website or web coating being run on a mobile gimmick. Usually, people use this condition to refer to web applications that are specifically optimized to work on wandering device. These apps are not installed; Instead, users open them in a web browser like Mobile Chrome or Mobile Safari.
Hybrid Apps
Hybrid App is the industry term habituate to depict a combination of Native App and Mobile Web App. Hybrid apps are installed like a native app, but implement some or all of their functionality via an embedded web browser, called a WebView.
When automatise a intercrossed application, users can swop between the Native and Web “ Contexts ” in order to control both parts of their coating. Seethis pagefor an example.
Appium vs Other Frameworks
Appium VS Espresso
Espresso is an Open Source model for automating Android applications. It ’ s establish into the Android SDK and does not indorse iOS.
Unlike Appium, Espresso code expects to run on the same machine as the gimmick under automation. The Espresso API is either compile into the app under mechanization or installed side-by-side. Espresso desegregate with Android Studio, however, Espresso code must be written in either Java or Kotlin.
Appium can use Espresso as the driver in an Android tryout, allowing it to make use of Espresso ’ s close integration with the device UI, while offering all the advantages of lyric independency and client/server architecture. This comes at the cost of slower tests, as Appium introduces an extra layer between automation code and device.
Appium VS XCUITest
XCUITest is Apple ’ s proprietary testing protocol, used for automating apps on iOS.
XCUITest can be used directly from XCode, Apple ’ s IDE, in order to run tests on attached iOS Simulators or Existent Devices. When used in this manner, XCUITest codification has to be written in Swift or Objective-C.
Appium uses XCUITest behind the panorama to automate iOS apps, with the added advantage of client/server architecture and words independence. This comes at the cost of slower tests, as Appium introduces an extra bed between mechanization code and device.
When running XCUITest code directly, users are limited to a single connected device. With Appium, multiple existent devices or simulator can be used to run tests in parallel, zip up tryout rhythm.
Appium VS Calabash
Calabash is BDD in Cucumber
Ruby only
Separation of logic and exam logic
Learn More in our Guided Bootcamp
Sauce Labs has a free Guided Bootcamp, demonstrating how to make and refactor your first automated test with Appium.Check it out here.
More Appium Resources
Jump to content
What is Appium?
How do Appium Work?
Appium and iOS
Appium and Android
Appium Capabilities
Appium App Compatibility
Appium vs Former Frameworks
Topics
Share this station
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