I'm using this command for getting UI Elements/XML of Apps based on WebView. In this case, I'm using the UPS app from the Play Store. This app is WebView based. Right now my device its using
"Android System WebView (Chromium) 99.0" i also tried "Bromite System WebView" but without success.
Sometimes, the dump actually work and I get the UI Elements and the xml file, but in some cases the xml file is empty, giving me nothing.
Command:
adb shell uiautomator dump /sdcard/file.xml
Related
I am building an Ionic 4 App + PouchDB, I have built the app by executing the command ionic cordova run android and for a few days, it works well. Recently though, the app just won't open anymore and I have no idea how to check what went wrong.
Prior to this, whenever something went wrong in the app, I am able to check it using the chrome://inspect. However, with the app not being able to open at all, it's impossible to check the cause of the problem since I am also unable to check using chrome://inspect.
When I tried to run it using ionic cordova run android -l, I get the same result, which is the app loads and closes a few moments later, and I'm still unable to get into chrome://inspect.
I had a hunch that it has something to do with PouchDB. The app starts to behave this way when the storage is almost reaching 200mb. Upon reading the PouchDB FAQ, it's stated;
In PhoneGap/Cordova, you can have unlimited data on both iOS and Android by using the SQLite Plugin.
But I am already using the SQLite Plugin for PouchDB, I have used cordova-sqlite adapter for my PouchDB too.
Below is an example of line in my code:
this._userdb = new PouchDB('user.db', { adapter: 'cordova-sqlite'});
With the app being unable to open, I'm out of ideas on how to retrieve the data stored inside PouchDB since I can't even get into the chrome://inspect at all (I can't see any console.log() for the stored data).
I feel like clearing the app data would allow the app to be opened as how it used to be but I really need to do a backup of the data stored inside PouchDB but I really have no idea how other than getting the console.log() of the data.
Is there any other way I can access the data stored inside the PouchDB to do the backup?
After many failed attempts to figure out how to retrieve the data stored inside PouchDB , I found one solution which is to pull the APK and extract the backup file.
By referring to this article, open CMD and shell into your device by;
adb shell
Provided that you know the app's package name, proceed to pull the APK by running;
adb backup -noapk com.app.your.package.name
**Note: Some devices like Samsung Galaxy stock Android 11 requires password to 'Backup my data'
Once pulled, you will find a backup.ab file and you need to extract this file. At this step, as a Windows user, I was unable to use the openssl method. I get an error using Python too.
But I found a solution that worked well for a Windows user. According to that solution;
Download Android Backup Processor
Go into the directory android-backup-tookit\android-backup-processor\executable (this directory should have a abp.jar file
Copy your backup.ab into this directory.
Open CMD, and run;
java -jar abp.jar unpack backup.ab test.tar
If the device was required password during the backup process, you will be asked to enter password. Enter the same password you provided during backup. Be sure to read the README for further details.
Once done, you will find test.tar file in the same directory. To view the file, simply extract it. The databases created inside the app should be in \test\apps\com.yourappname\f. The sqlite databases files can be viewed using DB Browser for SQLite.
When I click on Ui automator viewer after connecting my mobile device--> Device screenshot throws error
Error :
Error obtaining UI hierarchy Reason : Error while creating temporary file to save snapshot : null
Please let me know how to fix this issue?. Thanks
Download an old version of platform tools from Google
copy adb.exe and replace with current one in your SDK tools.
Source: https://softwaretestingboard.com/q2a/1654/appium-automator-viewer-could-android-emulators-screenshot#ixzz5qS8ez6GY
As I believe this app is not allow you to take screen shot from your device and from uiautomator as well.
As I am also getting same error but when I used to get the screenshot of other app it works fine but in the case of my app its not allowed to take screen shot using uiautomator.
So better way for now to get allow it by developer in test version of app so it works to get the element of app screens.
Take the screenshot and dump manually and open from "uiautomator". It will work. Use below commands to create and pull the dump from device:
-> adb shell uiautomator dump
-> adb pull /sdcard/window_dump.xml
Go to Ui automator, then select open file, select screenshot and corresponding dump xml file. Now we can see all the elements in UiAutomator tool.
Note: If you are using Mac-OS file should be window_dump.uix
There are two solutions :
1. Disconnect your device and reconnect. It should work.
OR
2. Kill all instances of adb.exe from task manager And restart UIAutomator. It should work.
I am taking those viewer using command prompt:
adb shell uiauomator dump
adb pull /sdcard/windows_dump.xml
reading those id manually
I am working in the layout files with XML have a TextView that must contain several special characters like "‡", "oe", "ƒ"... (even my browser failed to display them correctly, so I don't know if you got them right)
how can I write those characters in XML ??
will they be displayed correctly in android devices ??
Whenever this happens, I just uninstall the apk from the device itself and then try installing again using Android Studio.
In terminal window write "adb kill-server",and then run app again or uninstall the app from the phone and run again
How to view the output of log functions like GST_CAT_INFO, GST_DEBUG etc in Android environment? Can I view them in logcat?
The log is written to stderr. You can redirect it to a file (2>debug.log) and download it to your computer. There you can just read it using 'less' or 'more'. Alternatively disable the ansi colors (GST_DEBUG_NO_COLOR=1) and use gst-debug-viewer to interactively browse it.
There is a method to redirect stdio to the log so it is visible in logcat:
Redirect stdout to logcat in Android NDK
I have used this several times. I also remount /system read-write on android and edit "/system/build.prop" to add the setting so it survives a reboot. On development platforms, you can even use "vi" within adb shell to edit the file.
How can I test an application for performance in Android? What is the support provided in Android and how do I use it?
If you want to profile your application to find performance bottlenecks you can use the traceview tool. This gives you a graphical view of performance traces of your application.
To create a trace add the following to your code where you want to start tracing:
Debug.startMethodTracing("myapp");
and then put the following when you want to stop tracing:
Debug.stopMethodTracing();
This will create a trace file call myapp.trace in the root directory of the SD Card. As it is written to the SD Card:
If you're using the emulator you'll need to add an SD card to your AVD.
You'll need to give you app permission to write the SD card by adding the following to your Manifest:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Once the file has been created you'll need to copy it to your PC. You can do this using the adb command:
adb pull /sdcard/myapp.trace c:/my/dir/myapp.trace
Finally, start traceview giving it the full path to the trace file:
traceview c:/my/dir/myapp.trace
I did have some problems with traceview failing with OutOfMemory exceptions. I fixed this on Windows by changing the last line of traceview.bat from:
call java -Djava.ext.dirs=%javaextdirs% -Dcom.android.traceview.toolsdir= -jar %jarpath% %*
to:
call java -Xmx1g -Djava.ext.dirs=%javaextdirs% -Dcom.android.traceview.toolsdir= -jar %jarpath% %*
Adding the -Xmx1g option allows traceview to use more memory.
Also, theoretically, DDMS can get memory allocations for your program and then you can analyze the dump using profilers.
DDMS Reference.
The reason why I have theoretically in italics is that I myself have not tried doing anything such, yet.
I think traceView contains too much information, you can easily get lost.
My solution is just log the system time at three place in the code.
Before and after and center at the potiential slow code.
like binary search, next time, narrow it down step by step, then finally find the culprit code.
Another way to test is Using TruClient on Load Runner
Steps to be followed for Mobile Web are:
New VuGen Script
Mobile Protocol
Select TruClient Mobile Web
Click Create
Now you can generate scripts
Click Develop Script button
PoP up window appears to select the device
Select Actions and you can record the scripts
Steps to be followed for Native Mobile are:
New VuGen Script
Mobile Protocol
Select TruClient Native Mobile
Click Create
Now you can generate scripts
click develop script
TruClient window that plugged with Firefox appears
Click General Settings
Configure the SERVER URL PORT
If u don't know the server url port means install OS MONITOR application on your device. here you can find the ip address
Enter User Name and Password
Click done
you can record the scripts and perform your testing....
you can use load runner.,
use this link to find more about it.,
http://www.perftesting.co.uk/recording-and-performance-testing-android-applications-with-hp-loadrunner-vugen/2011/11/14/
Steps to be followed are:
Create New VuGen Script
Select Mobile Application-HTTP/HTML
Recording Options--> Select Record Emulator
Give the path to Record Emulator as D:\android\AVD Manager.exe
In the command line
-avd AVD_NAME -netspeed full -netdelay none
where AVD_Name is the name of your Device
select the working directory
click finish
Now you can perform your test.,