DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "iOS");
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "11.0");
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "Safari");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 8");
Mobile Test Automation
Mobile Test Automation - J2ME, Android and iOS
Sunday, February 16, 2020
Appium - iOS Safari Browser Capabilities
Thursday, February 13, 2020
Appium - Android Mobile Chrome Browser Desired Capabilities
public WebDriver mobileChromeDriver() throws MalformedURLException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("chromedriverExecutable",
"C:\\eclipse-workspace\\AppiumTestCases\\chromedriver.exe");
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, BrowserType.CHROME);
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "my phone");
capabilities.setCapability(MobileCapabilityType.VERSION, "8.0");
URL url = new URL("http://127.0.0.1:4723/wd/hub");
driver = new AndroidDriver(url, capabilities);
return driver;
}
Monday, February 10, 2020
Appium XPaths
Appium X-Paths
Android
Widget with Using class with index
driver.findElement(By.xpath("//android.widget.EditText[1]"));
Widget with Using class, text attribute
driver.findElement(By.xpath("//android.widget.Button[@text='Login']));
Widget with Using class and Resource ID
driver.findElement(By.xpath("//android.widget.Button[@resource-id='com.pkgname.xxx']));
Widget with Using text attribute and with different approaches.
//*[@text="foo"]));
//*[contains(@text, "fo")]
//*[@text='Text1' and ../*[@text='Text2']]
Widget with ID
//*[@id='ABC']
iOS
//UIAApplication[1]/UIAWindow[1]/UIAButton
//XCUIElementTypeStaticText[@name="YourText"]
//XCUIElementTypeButton[@name="YourText"]
Android
Widget with Using class with index
driver.findElement(By.xpath("//android.widget.EditText[1]"));
Widget with Using class, text attribute
driver.findElement(By.xpath("//android.widget.Button[@text='Login']));
Widget with Using class and Resource ID
driver.findElement(By.xpath("//android.widget.Button[@resource-id='com.pkgname.xxx']));
Widget with Using text attribute and with different approaches.
//*[@text="foo"]));
//*[contains(@text, "fo")]
//*[@text='Text1' and ../*[@text='Text2']]
Widget with ID
//*[@id='ABC']
iOS
//UIAApplication[1]/UIAWindow[1]/UIAButton
//XCUIElementTypeStaticText[@name="YourText"]
//XCUIElementTypeButton[@name="YourText"]
Wednesday, February 5, 2020
Android ADB Command - Get current application Package name and Activity name
ADB get package name and activity name in windows machine
Package Name
adb shell "dumpsys activity | grep top-activity"
Activity Name
adb shell "dumpsys activity activities | grep 'Hist #' | grep 'YOUR_PACKAGE_NAME'"
Package Name
adb shell "dumpsys activity | grep top-activity"
Activity Name
adb shell "dumpsys activity activities | grep 'Hist #' | grep 'YOUR_PACKAGE_NAME'"
Wednesday, August 5, 2015
UI Testing in Xcode 7
X Code 7 introduces a new UI testing feature for fully integrated
with X Code IDE. UI Testing, Recording and reporting are three major updates.
The core technologies are XCTest and Accessibility feature. It requires new OS
features iOS 9 and OS X 10.11 and Privacy protection for iOS devices enabled
for development and connected to a trust host running on XCode. OS X must grant
permissions to XCode helper for prompted on first run.
X Code is offering a target template that can target to be tested
“Cocoa Touch UI Testing Bundle (iOS)” and “Cocoa UI Testing bundle (OS X)”. This target can create an UI project under project source code and place the UI test cases into same project.
UI Recording
Interact with your app and generate
the code for new test cases and existing test cases. It will automatically find
UI elements with synthesizing your user events.
APIs
There are 3 new classes in this release.
XCUIApplciation
- Proxy for the tested Application and its run in a separate process
- Launching target app If any existing process is running, It will terminates any pre existing instance
- Its starting point for finding elements in the app
Example : Testing the Add
button
// Application
let app
= XCUIApplciation()
app.launch()
// Element and Query
let addButton =
app.buttons["Add"]
addButton.tap()
// Assertion
XCTAssertEqual(app.tables.cells.count,1)
- Element Type: Button,
Cell, Window, Etc.
- Identifiers:
Accessibility identifier, Label, Class, Etc.
- Element hierarchy:
Application is the root of tree elements. These elements can be used by
queries with type of element and its identifiers.
- Element uniqueness:
Every XCUIElement is backed by a query and every query must resolve
exactly one match like as XPath. If it matches multiple matches then
it cause the test failure. This can be found by using exists
property.
- Event synthesis: It
will simulate user interactions on elements. All APIs are
platform-specific.
For OS X:button.click();
For iOS : button.tap();
For iOS and OS X textField.typeText("Hello
World");
XCUIElementQuery
- This API can help us for specifying elements and Queries work based on relationships and filtering. Expressing relationships by Descendants, Children and containment.
- Filtering can be done by
Element Type:
Button, Table, Menu, etc.
Identifiers: Accessibility
identifier, label, title, etc.
Predicates:
Value, Partial matching and others
Combining relationships and Filtering
descendantsMatchingType()
childrenMatchingType()
containingType()
allButtons = app.descendantsMatchingType(.Button)
childButtons =
navBar.childrenMatchingType(.Button)
allCellsInTable
= table.descendantsMatchingType(.Cell)
cellQuery = cells.containingType(.StaticText,
identifier:”Groceries”)
Test case results
Show results for all tests
Pass/fail
Failure reason Performance metrics
ATBP - Android Testing Blue Print is now available !!!
Great collection of testing technique using the full spectrum of tools available to Android Testers. This repository will make it easy to get you started with test integration in existing and new projects. Android Testing Blue Print is available now on the android-testing-templates repository https://goo.gl/eSd8wC on Github. After cloning the repository please make sure you look at the “Getting Started Guide” first to get a glimpse of the project structure and how to run tests for each module.
https://github.com/googlesamples/android-testing-templates?linkId=16056862
Saturday, May 2, 2015
Espresso is faster than robotium
Espresso and Robotium are
instrumentation-based frameworks, meaning they use Android
Instrumentation to inspect and interact with Activities under test. The
major advances in Espresso over Robotium:
1.Synchronization: By default, instrumentation test logic
runs on a different (instrumentation) thread than UI operations (processed on
the UI thread). Without synchronization of test operations with UI updates, the
tests will be prone to flakiness - i.e. will fail randomly because of timing
issues. Espresso takes care of thread safety by seamlessly synchronizing test
actions and assertions with the UI of the application under test. Robotium
attempts to address this with sleep/retry mechanisms, which are not only
unreliable, but also cause tests to run slower than necessary.
2.API: Espresso has a small, well-defined and
predictable API, which is open to customization.
3.Clear failure information: Espresso strives to provide rich debugging
information when a failure happens. Further, you can customize the way failures
are handled by Espresso with your own failure handler.
For more information Read
More
Monday, April 27, 2015
Android new testing library update
Android new testing library update
|
The
new Android Testing Support Library provides an extensive framework for testing
Android apps with espresso and Android Junit Runner with Android Studio. Now
you can be able to run test cases from Android Studio with all connected
devices. This library provides a set of APIs that allow you to quickly build
and run test code for your apps, including JUnit 4 and functional user
interface (UI) tests. You can run tests created using these APIs from
the Android Studio IDE or from the command line. There are 3 major
updates 1) Android Junit Runner. 2) Espresso. 3) Uiautomator 2.0
Android
Junit Runner:
The Android Junit
Runner class is a JUnit test runner that lets you run JUnit 3 or
JUnit 4-style test classes on Android devices, including those using
the Espresso and UI Automator testing frameworks. The test
runner handles loading your test package and the app under test to a device, running
your tests, and reporting test results. This class replaces the Instrumentation
Test Runner class, which only supports JUnit 3 tests.
Uiautomator 2.0:
The UI Automator testing framework provides a set of APIs to build UI tests that perform interactions on user apps and system apps. The UI Automator APIs allows you to perform operations such as opening the Settings menu or the app launcher in a test device. The UI Automator testing framework is well-suited for writing black box-style automated tests, where the test code does not rely on internal implementation details of the target app.
Espresso:
|
The Espresso testing framework provides a set of APIs to build UI tests to test user flows within an app. These APIs let you write automated UI tests that are concise and that run reliably. Espresso is well-suited for writing white box-style automated tests, where the test code utilizes implementation code details from the app under test.
For more information Read More
Saturday, December 13, 2014
iOS-Deploy - Install and debug iPhone apps from the command line, without using Xcode
Install and debug iOS apps without using Xcode.
iOS-Deploy is will work on un-jailbroken devices. ios-deploy installation is
made simple by using the node.js package manager. If you use Homebrew,
install node.js: brew install node. You can install ios-deploy with
the node.js package manager: npm install -g ios-deploy
Examples:
Examples:
// deploy and debug your app to a connected device
ios-deploy --debug --bundle my.app
// deploy and launch your app to a connected device, but quit the debugger after
ios-deploy --justlaunch --debug --bundle my.app
// deploy and launch your app to a connected device, quit when app crashes or exits
ios-deploy --noninteractive --debug --bundle my.app
// Upload a file to your app's Documents folder
ios-deploy --bundle_id 'bundle.id' --upload test.txt --to Documents/test.txt
// Download your app's Documents, Library and tmp folders
ios-deploy --bundle_id 'bundle.id' --download --to MyDestinationFolder
// List the contents of your app's Documents, Library and tmp folders
ios-deploy --bundle_id 'bundle.id' --list
// deploy and debug your app to a connected device, uninstall the app first
ios-deploy --uninstall --debug --bundle my.app
// check whether an app by bundle id exists on the device (check return code `echo $?`)
ios-deploy --exists --bundle_id com.apple.mobilemail
// Download the Documents directory of the app *only*
ios-deploy --download=/Documents -bundle_id my.app.id --to ./my_download_location
// List ids and names of connected devices
ios-deploy -c
// Uninstall an app
ios-deploy --uninstall_only --bundle_id my.bundle.id
// list all bundle ids of all apps on your device
ios-deploy --list_bundle_id
For More Information
Read More
Monday, November 25, 2013
iOS App Stress testing
Existing android
monkey test technique
Android monkey test tool is a just
pseudo – random monkey testing tool. It is not android GUI verification tool.
It looks for only crashes and ANR by stressing your android application. Re
running the same test against with the same configuration will often reproduce
the crashes. If you can run the same test configuration on multiple devices
(Sony, Samsung, etc..) and different SDKs (4.3, 4.2, 4, 1, 4.0, 3.1, 3.2, etc...),
you can be able to catch bugs earlier in the development cycle of a new
release.
Android monkey test can execute the
below events and below constraints
Events
|
Touch
|
Track ball events
|
Navigation (up/down/left/right)
|
Sys keys (Home, Back, Start Call, End Call, or Volume controls)
|
Constraints
|
Package (-p) - App package name that you need to test ex:
com.example.myapp
|
Category (-c) - Visit
only specific activities that are listed with one of the specified categories
|
Beyond Monkey test technique http://en.wikipedia.org/wiki/Infinite_monkey_theorem
A sample monkey test report out put
Events injected: 1000000
: Dropped: keys=242 pointers=2342 trackballs=234
flips=423
## Network stats: elapsed time=100914ms (0ms mobile,
0ms wifi, 914ms not connected)
// Monkey finished
The same android monkey strategy can possible to apply for
iOS applications. iOS Uiautomation instrumentation tool is offering APIs for pound on our app with a barrage of taps,
swipes, device rotations, and even locking and unlocking the home screen. It
supports running automated tests in Instruments using JavaScript.
The same
android monkey technique is possible to apply for iOS apps by customizing Uiautomation
java script libraries.
A sample Java script test configuration
config:
{
numberOfEvents: 1000,delayBetweenEvents:
0.05,// In seconds
eventWeights: {tap: 30,drag: 1,flick:
1,orientation: 1,clickVolumeUp: 1,clickVolumeDown: 1,
lock: 1,pinchClose: 10,pinchOpen: 10,shake:
1},
touchProbability: { multipleTaps:
0.05,multipleTouches: 0.05,longPress: 0.05 }},
Ui- Auto-Monkey
Download the dependent java script libraries from: https://github.com/jonathanpenn/ui-auto-monkey/wiki
Installation
There's nothing special to install since this leverages UI
Automation and Instruments that come with Apple's developer tools. If you have
Xcode, you've got all you need to stress test your applications with UI
AutoMonkey. Follow the instructions below to set up a UI Automation Instruments
template with the UIAutoMonkey.js script.
First, load up your app in Xcode. Choose "Profile"
from the "Product" menu (or press Command-I) to build your
application and launch the Instruments template picker.
Next, you'll want to pick the "UI Automation"
template. You can add in other instruments to measure the app's performance
under the test after we set up the basic automation template.
Switch to the script pane by choosing "Script"
from the dropdown menu in the middle dividing bar of the Instruments document.
Create a script in this Instruments document by choosing
"Create..." from the "Add" button on the left sidebar.
Paste in the UIAutoMonkey.js script. At this point you can simply click the
playback button at the bottom of the Instruments window to start the script.
Once you've set up UI AutoMonkey in your Instruments
document, you can create a custom template tied to this application that you
can double click to run. First, make sure the Instruments document is stopped
by clicking the red record button in the upper left of the
Instruments document. Then choose "Save As Template..." from the
"File" menu and choose where to put the file. Now, you can double
click this template to open Instruments with the UI AutoMonkey script already
embedded. Just click the red record button in the upper left of the
Instruments document and the app will launch and run.
Still we need to customize and
improve for our needs Ex: Reporting at end of the test that should say crash
where in app, what - time, on what event, total time..etc.
Subscribe to:
Posts (Atom)