Skip to content

subprocess fails to export xml from adb window_dump commad #91653

Closed as not planned
@Miltonbhowmick

Description

@Miltonbhowmick

Bug report
I am using subprocess library to run command. I want to export xml file by using below functions. But the subprocess fails sometimes to export data. It was exporting previous command data from mobile screen. For the first run of grab_xml it does not export data of current screen, its grabbing data of previous situation.

Screen Demo:
bug_veve_scraping

My function to run a command:

def run_cmd(cmd):
    """ Runs scripts 
    Argumentss:
    cmd -> string command for script
    """
    proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
    out = str(proc.stdout.read())
    return out

My function to export data:

def grab_xml():
    run_cmd('adb -s device_id shell uiautomator dump && adb -s device_id pull /sdcard/window_dump.xml')
    with open("window_dump.xml", encoding='utf8') as infile:
        return str(infile.read())

Note: device_id means the id of device which is found by running adb devices command in command prompt
Your environment

  • CPython versions tested on: 3.10
  • Operating system and architecture: Windows 10 and x64 PC.

Metadata

Metadata

Assignees

No one assigned

    Labels

    pendingThe issue will be closed if no feedback is providedtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions