import subprocess,pathlib,time,os
root=pathlib.Path(os.environ['EVIDENCE_DIR'])
with open(root/f'new-terminal-{int(time.time())}.log','w') as log:
 for selector in ['role=button label=Back','role=button label=Terminal','label="Open new terminal, Start another shell for this thread"']:
  subprocess.run(['agent-device','press',selector,'--settle','--session','evidence-48865-mobile-retry'],check=True,stdout=log,stderr=log)
print('New terminal opened through UI')
