Get Current Focused Window Name using AndroidViewClient

前端 未结 1 1517
猫巷女王i
猫巷女王i 2021-01-16 17:12

I am using AndroidViewClient for testing my android application. I need to access name of current focused window. How can I get it?

相关标签:
1条回答
  • 2021-01-16 17:18

    It's a bit tricky but can be done. The information about the windows and focus is internally maintained by the Views under some conditions.

    You may try something like this (choose any view you have):

    ...
    vc = ViewClient(device, serialno, **kwargs2)
    vc.dump(window='-1')
    no_id1 = vc.findViewByIdOrRaise("id/no_id/1")
    no_id1.useUiAutomator = False    # this forces getting windows info
    no_id1.getXY()                   # this gets windows info
    print no_id1.windows[no_id1.currentFocus] 
    
    0 讨论(0)
提交回复
热议问题