AndroidViewClient是否有类似的用法device.getHierarchyViewer().focusedWindowName?
Does the AndroidViewClient has the similar usage device.getHierarchyViewer().focusedWindowName?
当我们使用MonkeyRunner做Android UI分析时,我们可以使用device.getHierarchyViewer().focusedWindowName快速获取当前屏幕的window名称.
然后我们可以使用window这个名字做一些基本的UI判断或者分析
而对于AndroidViewClient( git@github.com:dtmilano/AndroidViewClient.git ),它有类似的用法吗?
谢谢
device = MonkeyRunner.waitForConnection()
hViewer = device.getHierarchyViewer()
win_name = hViewer.getFocusedWindowName()
我认为已经回答了 here。
不过,我认为,由于大众需求,我将向 AdbClient 添加一个更直接的方法。也许 AdbClient.getFocusedWindowName()
是一致的。此 Window 与 View 层次结构无关,这就是为什么我认为它不适合作为 ViewClient 的公开方法。
欢迎评论。
编辑
好消息,AndroidViewClient 8.27.1 现在具有 AdbClient.getWindows()
、AdbClient.getFocusedWindows()
和 AdbClient.getFocusedWindowName()
。
您可以像这里一样使用它:
#! /usr/bin/env python
# -*- coding: utf-8 -*-
'''
Copyright (C) 2013-2014 Diego Torres Milano
Created on 2015-01-05 by Culebra v8.27.1
__ __ __ __
/ \ / \ / \ / \
____________________/ __\/ __\/ __\/ __\_____________________________
___________________/ /__/ /__/ /__/ /________________________________
| / \ / \ / \ / \ \___
|/ \_/ \_/ \_/ \ o \
\_____/--<
@author: Diego Torres Milano
@author: Jennifer E. Swofford (ascii art snake)
'''
import re
import sys
import os
try:
sys.path.insert(0, os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
except:
pass
from com.dtmilano.android.viewclient import ViewClient
kwargs1 = {'ignoreversioncheck': False, 'verbose': False, 'ignoresecuredevice': False}
device, serialno = ViewClient.connectToDeviceOrExit(**kwargs1)
print device.getWindows()
print device.getFocusedWindow()
print device.getFocusedWindowName()
顺便说一句,我很想知道您如何使用这些功能。是检查前置条件吗?
当我们使用MonkeyRunner做Android UI分析时,我们可以使用device.getHierarchyViewer().focusedWindowName快速获取当前屏幕的window名称.
然后我们可以使用window这个名字做一些基本的UI判断或者分析
而对于AndroidViewClient( git@github.com:dtmilano/AndroidViewClient.git ),它有类似的用法吗? 谢谢
device = MonkeyRunner.waitForConnection()
hViewer = device.getHierarchyViewer()
win_name = hViewer.getFocusedWindowName()
我认为已经回答了 here。
不过,我认为,由于大众需求,我将向 AdbClient 添加一个更直接的方法。也许 AdbClient.getFocusedWindowName()
是一致的。此 Window 与 View 层次结构无关,这就是为什么我认为它不适合作为 ViewClient 的公开方法。
欢迎评论。
编辑
好消息,AndroidViewClient 8.27.1 现在具有 AdbClient.getWindows()
、AdbClient.getFocusedWindows()
和 AdbClient.getFocusedWindowName()
。
您可以像这里一样使用它:
#! /usr/bin/env python
# -*- coding: utf-8 -*-
'''
Copyright (C) 2013-2014 Diego Torres Milano
Created on 2015-01-05 by Culebra v8.27.1
__ __ __ __
/ \ / \ / \ / \
____________________/ __\/ __\/ __\/ __\_____________________________
___________________/ /__/ /__/ /__/ /________________________________
| / \ / \ / \ / \ \___
|/ \_/ \_/ \_/ \ o \
\_____/--<
@author: Diego Torres Milano
@author: Jennifer E. Swofford (ascii art snake)
'''
import re
import sys
import os
try:
sys.path.insert(0, os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
except:
pass
from com.dtmilano.android.viewclient import ViewClient
kwargs1 = {'ignoreversioncheck': False, 'verbose': False, 'ignoresecuredevice': False}
device, serialno = ViewClient.connectToDeviceOrExit(**kwargs1)
print device.getWindows()
print device.getFocusedWindow()
print device.getFocusedWindowName()
顺便说一句,我很想知道您如何使用这些功能。是检查前置条件吗?