An XPath-based approach to reusing test scripts for android applications
The version of an Android application (app) is updated frequently and rewriting test scripts for each version update is laborious and expensive, so reusing existing test scripts is a better choice. Although the app's business logic is relatively stable during the process of app version evolution, user interface (UI) control changes in the new version tend to cause the original test scripts to fail, which is the main problem in test script reuse. In this paper we address this problem by developing an XPath-based approach to reusing test scripts for Android apps in the case of changes in the locations, names, or property values of UI controls in the app. In our approach, the test scripts use XPath expressions to locate the UI controls. The approach first identifies failed test scripts and no longer valid XPath expressions by executing the original test scripts on the new version of the app. Next, it uses the invalid XPath expressions to find the difference between the two DOMs corresponding to a view in the changed page in the new version and a view in the original page in the previous version, respectively. Finally, it uses the DOM difference to repair the XPath expressions, thereby achieving the reuse of test scripts. We have implemented a prototype of the approach based on Robotium and used it to conduct experiments on two real-world Android apps. The results show that our approach can achieve a higher script reuse percent than Robotium.