GUI testing is important for examining the end-to-end workflows and usability of GUI-based software. To reduce the manual effort of writing GUI tests, recent research has explored the potential of automatically reusing GUI tests by transferring them across similar applications. However, what is missing from the prior work is that such transfer may be required for apps available on different platforms. In particular, both web and Android are dominant platforms on which many organizations provide their software services. At the state-of-the-practice, even if the web and Android versions of an app provisioned by an organization substantially share the functionality, the developers have to manually write separate sets of tests for each version. This paper proposes TransDroid, an automated tool that transfers GUI tests from a web app to its Android counterpart. Evaluation of TransDroid on real-world web and Android apps corroborates its effectiveness by achieving 77% success rate among the attempted transfers, along with 82% precision and 99% recall in the mapping of the GUI events and oracles.
Python 3.7 with the following packages installed: Appium-Python-Client, astor, beautifulsoup4, editdistance, Flask, Flask-RESTful, gensim, html5lib, lxml, numpy, requests, scipy, selenium
Tested on Pixel 2 Emulator with API_25 (x86_64 image) and Windows 10
Download the zipped file (262MB) containing the subject apps and source code in our experiment
We suggest starting from a self-hosted ownCloud app to avoid possible issues from live websites (which are changing their UI rapidly and may invalidate the test cases used in our experiment)
Follow the tutorial to Install ownCloud web app with Docker Compose. The .env file used in our experiment is under TransDroid/script/owncloud-docker-server. Activate the web app with this command:
sudo docker-compose up -d
Now you should be able to connect to the ownCloud web app at localhost:8080 with the username and password defined in .env
Install subject/owncloud/com.owncloud.android_215.apk into the emulator. Open and configure the app to connect to your self-host server in step 1.
Start Appium-desktop
Run word2vec_service.py to activate the background web service for similarity query (modify the path in the source code pointing to GoogleNews-vectors-negative300.bin)
To run TransDroid, we suggest using PyCharm IDE.
Import the TransDroid folder into PyCharm and set appropriate interpreter or virtual environment for the project
Run Explorer.py. It will transfer the web test TransDroid/web_test/owncloud/TestSearchDetail.py (Technically, the JSON file aug_TestSearchDetail.json) to an executable Android test as TransDroid/android_test/owncloud/generated/TestSearchDetail.json
The generate JSON file can be executed with TransDroid/AndroidTestRunner.py
To try other transfers in our experiment, simply modify the config and test_name variables in Explorer.py accordingly (Before running the transfers for other subjects in our experiments, refer to the next section for their setup).
config = "config/owncloud/config.json" # change "owncloud" to other app name
test_name = "aug_TestSearchDetail" # change to other test names under the web_test folder
The subjects used in our experiments are under the subject folder
Wordpress
Web app: Install wordpress-5.3.2 locally in your (virtual) machine. Make sure the web app is accessible with an IP address/port via browser. Also, we rely on wp-cli for testing environment reset, e.g., clear the database. You can find the scripts/services we used in TransDroid/script/wordpress_service.py
Android app: Install the apk. You will need a WordPress.com account to setup self-hosted server in the app
GitLab
Web app: Follow the tutorial to install a GitLab server in your local machine with Docker Compose. The docker-compose.yml file used in our experiment is under TransDroid/script/gitlab/.env.
Android app: Connect to your self-hosted GitLab server
DokuWiki
Web app: Follow the tutorial to install a DokuWiki server in your local machine with Docker
Android app: Connect to your self-hosted DokuWiki server
The other web apps are their live website
https://www.buzzfeed.com/
TransDroid
Explorer.py: The main program of TransDroid
config: Configurations used by Explorer.py for web-to-Android transfer
web_test: Test suites for the web apps. To run the web tests, you will need a web driver such as ChromeDriver
android_test/APP/
generated: Android tests generated by TransDroid
ground_truth: Ground Truth
original: The Android Appium tests used to generate the ground truth
evaluator.py: Evaluate the generate Android tests based on their ground truth tests
augmentor.py: Augment an original web test
subject: the subject APKs used in our experiments
NavGraph: Executable and source code of the NavGraph Extraction component
The Navigation Graphs for the experimental subjects are included in the zipped file. If you want to generate the graph for your new app, first put the apk file, e.g., wpandroid-14.3-universal.apk under NavGraph\app\apk, and then execute:
cd TransDroid
sh script/transdroid-model-extractor.sh wpandroid-14.3-universal
You will see the related folders are generated in NavGraph\app\apktool-output and NavGraph\app\model
Note: The NavGraph Extrator is built on top of Soot, and because various reasons, e.g., kotlin-written app, obfuscated commercial apps, Soot version, etc., the extractor may not be able to analyze some apks. However, TransDroid is able to run without the information from static analysis. In this case, it relies on dynamic analysis only.
The logic of Context Extraction is implemented in several files: augmentor.py, AugUtil.py, ResourceParser.py, and widgetUtil.py.
Prepare the web app, Android app, and web tests (refer to the tests under TransDroid/web_test for the format)
Augment your web tests using augmentor.py, the augmented tests will be prefixed with aug_
Run the augmented web tests to get the JSON files (which contain the retrieved contexts for the web test)
Run Explorer.py to start the transfer