0

I want to send a message to all friends using IDs, my screen show only 12 IDs at a time. here I'm collecting all IDs in a list and sending messages to all 12 IDs, now I'm clear the IDs list and dragging the screen. now pick up the new IDs. So, I want to know that I have completely drag the screen till the end that I can terminate the outer loop.

name = list(vc.findViewsWithAttribute('class','javaClass'))
while True:
    for i in range(len(name)):
        try:
            vc.dump()
            name[i].touch()
            vc.dump()
            vc.findViewWithText('Chat').touch()
            new_message = message 
            vc.dump()
            message_field = vc.findViewByIdOrRaise("com.snapchat.android:id/chat_input_text_field")
            message_field.setText(new_message)
            time.sleep(1)
            vc.dump()
            d.press("input keyevent KEYCODE_ENTER")
            vc.dump()
            vc.findViewByIdOrRaise("com.snapchat.android:id/back_button").touch()
        except:pass
    try:
        name.clear()
        device.drag((200, 500), (200,180), 68, 20, 0)
        name = list(vc.findViewsWithAttribute('class','javaClass'))
    except: pass

I want to change while True: condition because It's an infinite loop.

1 Answers1

0

I think that something like this should work

last_name = None
name = list(vc.findViewsWithAttribute('class','javaClass'))
while last_name != name[-1]:
    for i in range(len(name)):
        try:
            vc.dump()
            name[i].touch()
            vc.dump()
            vc.findViewWithText('Chat').touch()
            new_message = message 
            vc.dump()
            message_field = vc.findViewByIdOrRaise("com.snapchat.android:id/chat_input_text_field")
            message_field.setText(new_message)
            time.sleep(1)
            vc.dump()
            d.press("input keyevent KEYCODE_ENTER")
            vc.dump()
            vc.findViewByIdOrRaise("com.snapchat.android:id/back_button").touch()
        except:pass
    try:
        name.clear()
        device.drag((200, 500), (200,180), 68, 20, 0)
        last_name = name[-1]
        name = list(vc.findViewsWithAttribute('class','javaClass'))
    except: pass

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134