How to take UI Automator dump for dynamic screens - appium

We are trying to automate an android screen in which there is a progress bar which gets updated every second. Our framework retrieves the UI dump using adb shell uiautomator dump to get the UI heirarchy layout and then parses the xml to take further actions. We observed that for the above mentioned screen we are not able to get the dump and the above command reports an error "Could not get idle state".
On the same screen, we tried with appium and appium is able to retrieve the elements on UI. How is appium able to retrieve the information, which UI Automator is not able to retrieve.? We would not want to integrate appium as a tool at this point in our framework and would like to use ui automator dump itself. Is there a way to overcome this issue?

The thing is that Appium has 2 drivers for Android: AndroidDriver and UIAutomator2Driver (for Android 5+)
The 2nd one is a custom client-server implementation of UIAutomator:
https://github.com/appium/appium-uiautomator2-server
https://github.com/appium/appium-uiautomator2-driver
So it literally means "Appium don't use UIAutomator as is" any longer.
Google is no longer supporting UIAutomator (last release was july 2017) in favour of Espresso.
Check code of server part and you will understand that with UIAutomator2 Appium overrides lots of original UIAutomator stuff to solve issues like you described and many more.
If you don't want to use Appium, you still can reuse UIAutomator2 Server or at least write your custom framework on its basis and solve issues of original UiAutomator.

Related

Object creation of UIAutomator or Appium

I need to record all Xpaths/resource in a when I click on an element in UIAutomator or Appium Inspector session. To do the above I need to create an Object of UIAutomator/Appium in my code so that I can run commands such as UIAutomator.recordElement() or along those lines to record the Xpaths which I clicked in a file.
I have used both Appium and UIAutomator to get the Xpaths but I have to manually copy and paste those Xpaths/resourceID from the interface to my code.
Example of Xpath :
//android.widget.LinearLayout[#content-desc=\"Numbers and basic operations\"]/android.view.ViewGroup[1]/android.widget.Button[9]"
The above path was obtained from Appium while using the Calculator App in an Android Emulator via manual copy and paste.
I need to get it automatically.
In Appium Desktop there is "Start Recording" button
which automatically captures the actions you perform in the mobile application or website and translates it into the code in variety of programming languages/frameworks
You might also want to try out Appium Studio which makes the processes of managing devices/emulators, recording and tests execution much easier.

How to view saved page source in Appium app

While running automated test using appium I used driver.getPageSource() and stored it as a XML file. I also took the screenshot of the same page using driver.takeScreenshot() and saved it as a PNG file. Now how do I view it in Appium app so that it correspondingly maps to the elements with the xml data.
Is there a open option in Appium like in uiautomatorviewer?
I couldn't use uiautomator because it requires uix file. But I couldn't find open option in appium.
UIAutomatorviewer is simple tool to start with mobile automation , however it has some limitations
Less robust:
Throws random errors while working with native apps
Limited functionality:
Limited features as compared to APPIUM Desktop
These limitations do not allow UIAUTOMATORVIEWER to be a universal choice among the automation engineers , and mostly it’s used along with Appium Desktop.
For Installation and Usage you can refer below URL
https://automationlab0000.wordpress.com/2018/12/31/appium-desktop-for-locating-elements/
Due to the complex setup of Appium, it is quite difficult to be dependant only on Appium for mobile automation.
With Appium Studio of SeeTest you can easily identify objects.
Appium Studio mitigates all of Appium's challenges with ease. There is also an object spy for easier object and XPath identification. Tests are recorded simply. Actions carried out on the device reflection are recorded in an easily exported and executable test written in the language of your choice.
Visit this blog for more details.
Refer their docs to get started https://docs.experitest.com/display/public/TD/Appium+Studio

For mobile automation what are the advantages of Appium VS Calabash and of Calabash VS Appium?

I have used Appium in Mobile automation with IOS and Android. I wanted to know about advantages that offers Calabash and if there are common point in generated scripts of both tools?
I have followed this link : Appium VS Calabash
I have hands on in mobile automation quite a long time. let me tell my point of view on both tools.
both also have advantage and disadvantage find below:
I have used calabash and appium both for automation. Appium has more advantages than calabash.
Advantages of Appium over Calabash:
1. You can write your code in multiple language like Java,Python, C#, php etc. However, Calabash restrict to use RUBY only.
Appium comes with many predefined methods such as OpenNotification(), StartActivity(), InstallApp etc. Calabash does not provide such predefined methods.
Appium set up is very easy as compared to Calabash.
In calabash, it installs the app on the device every time you run the test. However, In appium you have a feature where in you don't need to install the app every time. It works with previously installed app on the device.
Appium works with both native and hybrid app.
There are many advantages of appium. I hope this helps.
Try them both for yourself.
I found calabash easier to get started. I had a complete user flow test working from setup to working test in Calabash in half the time it took for Appium.
I don't like using xpath. It makes tests brittle and subject to breakage if something in the layout changes. Appium requires mainly the use of xpath. Calabash allows you to drive actions and interactions through the selection of elements by their text . I prefer this because that same text is normally in the designs and/or requirements.
Some comments in other posts are not accurate. Calabash does not require the install of the app every time unless you don't look beyond the surface. There is a simple means to enable/disable it. I have logic that runs either way based on passing an argument. Calabash has more than enough existing methods to interact with your app. It has a built in debug that allows you to tinker with element interaction and those same calls can be copied and reused in your test code. Using it with getgauge.io provides reporting akin to the built in Cucumber but is easier to run multi-threaded and easier to write your feature/spec files.
Be fair to both tools and yourself. Create a simple project in each and try for yourself. Don't make a decision solely based on someone else's opinion.
There is no common part in the automation scripts since Calabash uses query for interacting elements but Appium uses selenium find functions.
The best part of the Calabash is that you can use cross-platform frameworks for automating ios and android application with same feature file and most part of automation code. However the worst part is that Calabash is Ruby only.
Look at this post for more details about the differences of Calabash and Appium.
Since you have already read the differnces , Few things to note that Calabash can also be used with Xamarin which is also a good tool to test hybrid apps and you can run the same script for ios and android apps with some minor changes.Also it has been now integrated into visual studio,so microsoft support is inevitable and some users might feel comfort factor.Lambda expressions are also a plus.A major setback with the Calabash however that it only uses ruby.
Appium on the other hand can support various languages which is plus and you can use webdriver as well.However it struggles with hybrid apps but you can overcome that functionality by using google chrome mobile view to find coordinates to click.one thing for sure is that sause labs have many bugs to fix in Appium yet.

Writing tests in Appium for ActionScript-based iPad app

I downloaded and set up Appium to run tests for an app developed in ActionScript for the iPad. I can run Appium just fine, however am having trouble actually writing tests. The problem is that I don't have any way to retrieve elements from the app. I thought I could do this with the selenium driver (I am currently creating an IOSDriver with Appium), however can't seem to figure out exactly how. All of the elements created by my application are flash-based (TextField for example), so I'm not sure how to retrieve them with the normal findElement method(s).
(Note I cannot update the code to comply with my tests, it must be the tests that comply with the pre-written code)
The Accessibility-based mechanism underlying the UI Automation feature represents every control in your app as a uniquely identifiable element. To perform an action on an element in your app, you explicitly identify that element in terms of the app’s element hierarchy.
This link is useful Tutorial
Tools You may like to try Although they are not exactly like UiAutomatorViewer which is for android
Reveal App
SparkInspector
Ios Hierarchy-Viewer
As far as Flas Elements concers Lets Look at this tutorial.

How do I automatically create performance reports for an iOS app?

For some of my iOS application projects, I would like my CI server to be able to report the following properties:
startup time
frame rate
both as a graph over time, and with "low water marks" so the build fails if the measured results aren't within certain criteria. I've already found some of the things I need.
The CI server will be Jenkins.
I can use Transporter Chief to get the built app onto an iPad.
To measure the startup time I could find the duration between launching main() and leaving application:didFinishLaunchingWithOptions:.
To measure frame rate I can put a CADisplayLink into the app and sample its duration property.
If those tests output JMeter XML, then Jenkins can display the output via the Performance plugin.
What I haven't worked out is, how should I embed those tests into my app and launch it on the iPad? As described above I can deploy the app to the iPad, but then I don't know how I would launch it to gather the results of the tests. My unit tests are running on the simulator - I don't want to run the performance tests there obviously :-).
I imagine that there's a solution involving jailbreaking the iPad and controlling the app over SSH, I'd prefer not to go down that route if it's possible. If you have done that and can explain how it works, I'd still like to hear about it.
I'm also using fruitstrap to install apps on the device in CI. In terms of booting the app, I know of two ways:
Use fruitstrap with the debugger attached
I know teams that have done this to run KIF integration tests on devices in CI. I have played around with fruitstrap to get it booting apps on the device, but haven't myself taken the extra step of automating the whole thing
shameless plug for my post on fruitstrap: http://www.stewgleadow.com/blog/2011/11/05/installing-ios-apps-on-the-device-from-the-command-line/
Use the instruments command line tool with UIAutomation
I know the instruments tool can boot apps on the device automatically in CI (I wish it also installed them, but we have fruitstrap for that until Apple fixes it). So you could write a really simple little UIAutomation test that gave your app enough time to do its performance analysis.
Jonathan Penn has a nice little demo project for UIAutomation and build script that could be integrated with an 'install' step using fruistrap to try it out on the device
In both cases, I uses a little wrapper around libusb to give me the device ID of attached devices, so the more devices I plug into my CI machine, the more devices it runs tests on, https://github.com/sgleadow/iphone_detect
Can you launch the app on the device using lldb?
If so, it may also be able to capture the log output.

Resources