Pages

APPIUM Tutorial

 What is APPIUM?

It is a widely used tool for Mobile Testing.

Appium is mobile web,native and hybrid software application test automation tool developed and suppoorted by sauce lab

It is open-source software automation tool which is useful to automate android and IOS platform apps.


Why we need Mobile?

Importance of Moblie:-

I want to pay my electricity bill.

I need to communicate with my manager and submit my reports urgently.

If you want to buy grocerys, clothes, book all tickets can do with mobile.

Now answer yourself. What do you need to perform these  activities in a fraction of seconds

with ->A smartphone,

        ->Internet connectivity 

         ->A mobile app to do the job.

 

 Various  Mobile OS(operating system)

      Operating system                       Developed by                                  Popularity

      Android                                      Google Inc                                          High

       IOS                                             Apple Inc                                            High

        BlackBerry                               BlackBerry Ltd                                    Low

        windows                                   Microsoft Inc                                      Medium

Types of Moblie Apps

 Mobile web Apple:

 

 -Web apps not real applications: they are actually websites that open in your smartphone

 with the help of a web browser.  Mobile websites have the broadest audience of all the primary types of applications.

 

 Native App

- A native app is developed specifically for one platform. It can be installed through an application store (such as Google play store or Apple's App Store).

Example- Whatsapp, Facebook, This app can use all the system application's(the apps which comes by default with your mobile)


Hybrid App

hybrid Apps are a way to expose content from existing websites in App format. They can be well described as a mixture of Web App and Native App

what is Appium?

Appium is mobile web,native and hybrid software application test automation tool developed and suppoorted by sauce lab

It is open-source software automation tool which is useful to automate android and IOS platform apps.

why Appium(Advantages)?

Cross platform:Android&ios:we can test native,hybrid,web app

Allows you to communicate with other apps,Ex:Whatsapp(Majority of tools doesn't support this)

No pre-compilation of your app

support for built-in app:alarm,phone,calendar etc

Any WebDriver compatible language is supported:Java,objective,C,Ruby,php,C#,:we just need language specific libraries to work on


Limitation of Appium:

For Android,No Support for Android API <17(for android v>4.1) if you mobile having less than 17 then we need to go for selendroid.

Script Execution is very slow on ios platform & android virtual devices

No support for Toast messages; we can handle this

no parallel execution directly:we can handle using sauce labs

APK:Android Application package.

IPA:Iphone Application package.


This is similar to .exe file which are used to install programs on windows.

The only difference is .apk file are designed to be used exclusivley on Android  devices

and you may be required to download addtional files before you run the appliacation

in the android.


Why we are using them what is the use?

we are going to test mobile appliacation means once after the application

was developed in android it will be apk file only.So to automate 

we need apk file, generally in real time we can get this apk file from 

the developer and for generic application we can download from playstor too.


What is Real Testing Device?

Testing on real device allows you to run your mobile apllication 

and checks its functionality.Real device Testing assures you that our appliacation

will work smoothly in customer handsets


What is Emulator and simulator?

Emulator and Simulator are virtual devices.A virtual is not the real

phone but software which gives same functionality as the real phone (Except few functionality like the camers


Android virtual devices :Emulator.

IOS virtual device: Simulator.

How Appium work?

  • When we install the Appium, a server is also installed with it on our machine that exposes the REST API.
  • It receives command and connection requests from the client and executes that command on devices like iOS or Android.
  • It replies with the HTTP responses.
  • To execute requests, it uses a mobile test automation framework to run the user interface of the app. For Example -
    • Apple instruments used for iOS
    • Selendroid used for Android API 15 or less
    • UIAutomator used for Android API 16 or higher


What are the locators in appium?

Id, Name, ClassName, XPath, AndroidUIAutomator,  AccessibilityId.

Status:

Retrieve the server’s current status:

driver.getStatus();

Session:

Create New Session:

IOS :
DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability(MobileCapabilityType.PLATFORM_VERSION, "10.3"); dc.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone Simulator"); dc.setCapability(MobileCapabilityType.AUTOMATION_NAME, "XCUITest"); dc.setCapability(MobileCapabilityType.APP, "/path/to/ios/app.zip"); URL url = new URL("http://127.0.0.1:4723/wd/hub");

IOSDriver driver = new IOSDriver(url, dc);

ANDROID:

DesiredCapabilities dc = new DesiredCapabilities();

dc.setCapability(MobileCapabilityType.AUTOMATION_NAME, "UIAutomator2");

dc.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator");

dc.setCapability(MobileCapabilityType.PLATFORM_VERSION, "11.0");

dc.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");

URL url = new URL("http://localhost:4723/wd/hub");


AndroidDriver<WebElement> driver = new AndroidDriver<WebElement>(url, dc);

End Session:

End running session:

driver.quit()

Get session capabilities:

Retrieve the capabilities of the specified session

Map<String, Object> caps = driver.getSessionDetails();

Take ScreenShot:

File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);

Get PageSource:

Get the current application hierarchy XML (app) or page source (web)

String pageSource = driver.getPageSource();

Set TimeOuts:

Configure the amount of time that a particular type of operation can execute for before they are aborted

driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);

Set Impilicit wait:

Set the amount of time the driver should wait when searching for elements

driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

SetScriptTimeout:

Set the amount of time, in milliseconds, that asynchronous scripts executed by execute async are permitted to run before they are aborted (Web context only)

driver.manage().timeouts().setScriptTimeout(30, TimeUnit.SECONDS);


Orientation:

Get Orientation:

Get the current device/browser orientation

ScreenOrientation orientation = driver.getOrientation();

Set Orientation:

Set the current device/browser orientation

driver.rotate(ScreenOrientation.LANDSCAPE);
driver.rotate(ScreenOrientation.PORTRAIT);
GeoLocation:
Get GeoLocation:

Get the current geo location

Location location = driver.location(); // Must be a driver that implements LocationContext

Set GeoLocation:

Set the current geo location

driver.setLocation(new Location(49, 123, 10)); // Must be a driver that implements LocationContext

Logs:
Get All Available Loges Types

Get available log types as a list of strings

Set<String> logTypes = driver.manage().logs().getAvailableLogTypes();

Get the log for a given log type. Log buffer is reset after each request

LogEntries logEntries = driver.manage().logs().get("driver");

LOG Events:

Store a custom event

CustomEvent evt = new CustomEvent(); evt.setEventName("funEvent"); evt.setVendor("appium"); driver.logEvent(evt);


Get Events:

Get events stored in appium server

driver.getEvents();

UPDATE Device SETTINGS:

Update the current setting on the device

driver.setSetting(Setting.WAIT_FOR_IDLE_TIMEOUT, 5000);

Retrive Device Settings:

Map<String, Object> settings = driver.getSettings();

Execute Driver Script:

Run a WebdriverIO script against the current session, allowing execution of many commands in one Appium request.

String script = "const el = await driver.$('~foo');\n" + "await el.click();"
driver.executeDriverScript(script, new ScriptOptions().withTimeout(200));










No comments:

Post a Comment

Note: Only a member of this blog may post a comment.