Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can not use the examples browser-open-url.py #303

Closed
joanyy opened this issue Jun 9, 2022 · 2 comments
Closed

can not use the examples browser-open-url.py #303

joanyy opened this issue Jun 9, 2022 · 2 comments

Comments

@joanyy
Copy link

joanyy commented Jun 9, 2022

Hi , i used pip3 and git methods to install androidviewclient, then i can use dump , but i cannot find the fold of androidviewclient(only one on /usr/local/lib/python3.8, but it does not include examples files ), so i don't know how to write on the path of 'android_view_client_home' . when i run your example,browser-open-url.py , there is an error "ERROR: couldn't find device that matches '/home/xxxx/.local/share/jupyter/runtime/kernel-9a30b3cf-a1f5-4f11-8bbf-004e1f28b704.json' in [<com.dtmilano.android.adb.adbclient.Device object at 0x7fbc70184c40>]
"

@joanyy
Copy link
Author

joanyy commented Jun 9, 2022

I want to crap long mobile screenshots in bulk by androidviewclient, can i do it? i mean can i get paramenters from my apk and put params into apk? e.g., i want to put url list into the 'webview'(android studio), then automatically display each url and take a screenshot. do you have any suggestions for this?

@dtmilano
Copy link
Owner

Using pip3 is what you need if you are not planning to change *AndroidViewClient code.

Once installed you have dump and culebra commands available.

Also, you will be able to import AndroidViewClient modules, for example

from com.dtmilano.android.viewclient import ViewClient

That's all you need.

I don't understand what you mean by "...can i get parameters from my apk and put params into apk?".
Can you give an example of that?

Also, if I understood correctly you want to open different URLs in the browser and then take the screenshot, if so this should do what you want

#! /usr/bin/env python3

import sys

from com.dtmilano.android.viewclient import ViewClient

if len(sys.argv) < 2:
    print(f'usage: {sys.argv[0]} url...', file=sys.stderr)
    sys.exit(1)

urls = sys.argv[1:]
sys.argv = [sys.argv[0]]

device, serialno = ViewClient.connectToDeviceOrExit()
cmp = 'com.android.chrome/com.google.android.apps.chrome.Main'

for n, url in enumerate(urls):
    device.startActivity(component=cmp, uri=url)
    ViewClient.sleep(5)
    device.takeSnapshot(reconnect=True).save(f'/tmp/{n}.png', 'PNG')

invoke it like

./myscript http://google.com http://github.com http://dtmilano.blogspot.com

@dtmilano dtmilano closed this as completed Jul 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants