Adb Not getting screen elements in xml file after some time

24 views Asked by At

I am using adb to automate the chrome. But after some time it does not get the screen elements in xml file.. no idea why this is happening and how to solve it.

this is my code to get the xml file and to parse the xml file.

def get_xml(device):
    d = device.replace('.','_')
    d = d.replace(':','')
    commands = [rf'C:/platform-tools/adb -s {device} shell uiautomator dump',
                rf'C:/platform-tools/adb -s {device} pull sdcard/window_dump.xml {d}.xml']
    for command in commands:
        p = subprocess.Popen(command, shell=True, stdout = subprocess.PIPE)
        sleep(1)
def parse_xml(device):
    d = device.replace('.','_')
    d = d.replace(':','')
    try:
        tree = ET.parse(f'{d}.xml')
        root = tree.getroot()
        nodes = root.findall(".//node")
        return nodes
    except Exception as e:
        # print(e)
        get_xml(device)
        return parse_xml(device)
0

There are 0 answers