Appium overview

26
Get a start with for Mobile Automation (Android) TPC DECEMBER 2016 MEETUP BY ABHISHEK YADAV (@ABHISHEKKYD)

Transcript of Appium overview

Page 1: Appium overview

Get a start with

for Mobile Automation (Android)TPC DECEMBER 2016 MEETUPBY ABHISHEK YADAV (@ABHISHEKKYD)

Page 2: Appium overview

Agenda

Overview of Mobile Automation  About Appium  Overview of Appium over other open source tools Android Installation with emulator  Scripting using Appium for Mobile Web Automation Scripting using Appium for Mobile App Automation Framework Development using Appium Appium iOS Automation

Page 3: Appium overview

Overview of Mobile Automation

Now a days every organization prefers automated testing once a product reaches to the stable phase to reduce the testing effort. Since testing cost is an important factor for any project, organizations have started preferring open source test automation tools (which have reached a stage where they now rival the commercial ones) instead of investing in costly commercial testing tools. A variety of open source automation testing tools is available for almost all types of testing such as functional, UAT, regression, performance etc. Some open source tools are Appium, Calabash, MonkeyTalk, Robotium, etc.

Page 4: Appium overview

About Appium

Appium is an open source test automation framework for use with native, hybrid and mobile web apps. 

It drives iOS, Android, and Windows apps using the WebDriver protocol.

Importantly, Appium is “cross-platform”: it allows you to write tests against multiple platforms (iOS, Android, Windows), using the same API. This enables code reuse between iOS, Android, and Windows testsuites.

Page 5: Appium overview

About Appium

Webdriver Controller

Instruments Controller

Instruments Command Server

Unix Socket Server

Instruments Command Client

Unix Socket Client

Instruments

Bootstrap.js

Page 6: Appium overview

About Appium

Webdriver Controller

UIAutomator Controller

UIAutomator ClientTCP Client

Bootstrap.jar

UIAutomator ServerTCP Server

Page 7: Appium overview

About Appium

Page 8: Appium overview

Overview of Appium over other open source tools

A huge number of mobile testing tools have been developed in recent years to support mobile development. As more companies are developing mobile products and the marketplace is seeing more devices, platforms, and versions, testing your mobile apps is vital. When it comes choosing what mobile testing tool is right for you, there is a huge array of options, each with different strengths and weaknesses.

Page 9: Appium overview

Overview of Appium over other open source tools

Page 10: Appium overview

Android Installation with emulator

Android Studio provides the fastest tools for building apps on every type of Android device.

World-class code editing, debugging, performance tooling, a flexible build system, and an instant build/deploy system all allow you to focus on building unique and high quality apps.

https://developer.android.com/studio/index.html

Page 11: Appium overview

Android Installation with emulatorAndroid Studio GUI

Page 12: Appium overview

Android Installation with emulatorandroid

android avd

Command

Line }

Page 13: Appium overview

Scripting using Appium for Mobile Web Automation

DesiredCapabilities capabilities = new DesiredCapabilities();capabilities.setCapability("deviceName", "TestAndroid");capabilities.setCapability("platformName", "Android");capabilities.setCapability(CapabilityType.BROWSER_NAME, "browser");capabilities.setCapability("platformVersion", "5.1");

driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);driver.get("http://www.google.com");

WebElement keyword = driver.findElement(By.name("q"));keyword.sendKeys("Hello Selenium");

Page 14: Appium overview

Scripting using Appium for Mobile App Automation

DesiredCapabilities capabilities = new DesiredCapabilities();capabilities.setCapability("deviceName", "TestAndroid");capabilities.setCapability("platformName", "Android");capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");capabilities.setCapability("platformVersion", "5.1");capabilities.setCapability("appPackage", "com.android.calculator2");capabilities.setCapability("appActivity","com.android.calculator2.Calculator");

driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);

Page 15: Appium overview

Framework Development using Appium

Apache Maven Page Objects TestNG ReportNG Allure Cucumber (BDD) Jenkins

Page 16: Appium overview

Advanced Locator Strategies

MobileBy ByAccessibilityId ByAndroidUIAutomator

Page 17: Appium overview

MobileByDesiredCapabilities capabilities = new DesiredCapabilities();capabilities.setCapability("deviceName", "TestAndroid");capabilities.setCapability("platformName", "Android");capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");capabilities.setCapability("platformVersion", "5.1");capabilities.setCapability("appPackage", "com.android.calculator2");capabilities.setCapability("appActivity","com.android.calculator2.Calculator");

driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);

driver.findElement(MobileBy.name("4")).click();

Page 18: Appium overview

ByAccessibilityIdDesiredCapabilities capabilities = new DesiredCapabilities();capabilities.setCapability("deviceName", "TestAndroid");capabilities.setCapability("platformName", "Android");capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");capabilities.setCapability("platformVersion", "5.1");capabilities.setCapability("appPackage", "com.android.calculator2");capabilities.setCapability("appActivity","com.android.calculator2.Calculator");

driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);

driver.findElement(MobileBy.name("4")).click();driver.findElement(MobileBy.AccessibilityId("delete")).click();

Page 19: Appium overview

ByAndroidUIAutomatorDesiredCapabilities capabilities = new DesiredCapabilities();capabilities.setCapability("deviceName", "TestAndroid");capabilities.setCapability("platformName", "Android");capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");capabilities.setCapability("platformVersion", "5.1");capabilities.setCapability("appPackage", "com.android.calculator2");capabilities.setCapability("appActivity","com.android.calculator2.Calculator");

driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);

driver.findElement(MobileBy.AndroidUIAutomator("new UiSelector().text(\"3\")")).click();

Page 20: Appium overview

Appium iOS Automation

Page 21: Appium overview

Appium iOS Automation

IosUIAutomation

driver.findElementByIosUIAutomation("tableViews()[0].cells(1).textViews()

.firstWithPredicate(\"name == New Delhi And NCR\")");

Page 22: Appium overview

Selenium

Version

Page 23: Appium overview

Selenium 3.0 Launched!! Selenium 3.X is no longer capable of running Selenium RC directly,

rather it does it through emulation and the WebDriverBackedSelenium interface.

You’ll need to be running Java 8 to use the Java pieces of Selenium. This is the oldest version of Java officially supported by Oracle, so hopefully you’re using it already!

Support for Firefox is via Mozilla’s geckodriver. Support for Safari is provided on macOS (Sierra or later) via Apple’s

own safaridriver. Support for Edge is provided by MS through their webdriver server. Only versions 9 or above of IE are supported. Earlier versions may

work, but are no longer supported as MS no longer supports them.

http://www.helloselenium.com

Page 25: Appium overview
Page 26: Appium overview