Frage

I'm using monkeyrunner and androidviewclient to crawl the GUI of some android apps (i.e., this). BTW, it is working great! The thing is that sometimes when you click on a clickable component it will open up the same page that you are in or you have been in this it before. For example, you're in the home directory of your app and you click the home link or the app logo then you go to the same page (i.e., home directory of the app again!). I want to avoid these kind of cases. In other words, this can cause of an infinite loop of clicking. Is there any idea or heuristics for measuring the similarity between two activity pages. Or I should ask, what metrics are good for measuring the similarity between two pages, num of elements, text or etc.

War es hilfreich?

Lösung

Once you have dumped the tree you can save it and then use some distance calculation against the new dump. For example:

# dump the tree
tree1 = vc.dump()
# do something, here, like touch to navigate
someView.touch()
# dump again
tree2 = vc.dump()
# calculate the distance
d = distance(tree1, tree2)

Obviously, the trick is in how to select the distance method. You can convert the trees to strings and then calculate the Hamming distance if they are the same length, or Levenshtein distance if they are not.

I have been using this method on some projects. The only thing you should consider to apply the later is the size of the strings, as the matrices become very big. Future versions of AndroidViewClient will include some of these facilities.

Alternatively, you can do some visual comparison as described here.

Andere Tipps

XMLUnit might be what you're looking for, http://xmlunit.sourceforge.net/

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top