You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code below take forever when view_list and view_list2 is different:
#! /usr/bin/env python
import sys
import os
import hashlib
from com.dtmilano.android.viewclient import ViewClient
reload(sys)
sys.setdefaultencoding('UTF8')
# PyDev sets PYTHONPATH, use it
try:
for p in os.environ['PYTHONPATH'].split(':'):
if not p in sys.path:
sys.path.append(p)
except:
pass
try:
sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
except:
pass
def get_clickable_view_list(_view_list):
result_view_list = []
for each_view in _view_list:
if each_view.isClickable():
result_view_list.append(each_view)
return result_view_list
def get_string_of_view_list(_view_list):
string = ""
for each_view in _view_list:
string += str(each_view)
return string
vc = ViewClient(*ViewClient.connectToDeviceOrExit(verbose=True))
view_list = vc.dump(sleep=0)
print(hashlib.sha1(get_string_of_view_list(view_list)).hexdigest())
for view in get_clickable_view_list(view_list):
if "Chat" in view.getContentDescription():
view.touch()
view_list2 = vc.dump(sleep=0)
print(hashlib.sha1(get_string_of_view_list(view_list2)).hexdigest())
print(get_string_of_view_list(view_list) == get_string_of_view_list(view_list2))
print(str(vc.distance(view_list, view_list2)))
# print(str(vc.hammingDistance(view_list, view_list2)))
# print(str(vc.levenshteinDistance(view_list, view_list2)))
If I CTRL+C the result is like this:
jihunimimac:examples jihun.im$ python playground.py
Connecting to a device with serialno=.* with a timeout of 60 secs...
Connected to device with serialno=.*
Actual device serialno=ENU7N15A30003855
6b766238ea1b51f2b18ac62150e61ba27be21ba7
578e476a82026b3e74a5bbefe17b5682c0e299f1
False
^CTraceback (most recent call last):
File "playground.py", line 58, in
File "/usr/local/lib/python2.7/site-packages/com/dtmilano/android/viewclient.py", line 4195, in distance
return ViewClient.__levenshteinDistance(s1, s2)/t
File "/usr/local/lib/python2.7/site-packages/com/dtmilano/android/viewclient.py", line 4296, in __levenshteinDistance
cost = 0 if s[i-1] == t_j else 1
KeyboardInterrupt
Additionally, hammingDistance and levenshteinDistance has following Error even though I gave 2 arguments!:
Traceback (most recent call last):
File "playground.py", line 53, in
print(str(vc.hammingDistance(view_list, view_list2)))
TypeError: hammingDistance() takes exactly 2 arguments (3 given)
The text was updated successfully, but these errors were encountered:
The code below take forever when view_list and view_list2 is different:
If I CTRL+C the result is like this:
Additionally, hammingDistance and levenshteinDistance has following Error even though I gave 2 arguments!:
The text was updated successfully, but these errors were encountered: