-
Notifications
You must be signed in to change notification settings - Fork 2
/
topsite-screenshots.py
31 lines (22 loc) · 1.13 KB
/
topsite-screenshots.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
import sys, csv
browsers = ['com.android.chrome/.Main',
'org.mozilla.fennec/.App']
def main():
# Connects to the current device, returning a MonkeyDevice object
device = MonkeyRunner.waitForConnection()
#Start each browser activity with the provided URI
for run, browser in enumerate(browsers):
# Visit each site
for visit, site in enumerate(csv.reader(open(sys.argv[1]).readlines())):
# Start the activity with the provided site
device.startActivity(component=browser, uri=site[0])
# Wait for page load timeout
MonkeyRunner.sleep(20) # Sleep 20 seconds between page loads
# Snap a screenshot of the running activity
device.takeSnapshot().writeToFile("%s%s-%s.png" % (sys.argv[2], visit, run), 'png')
if __name__ == "__main__":
main()