#!/usr/bin/env python __author__ = 'Daniel Berrange ' from dogtail.tree import * from dogtail.distro import * from dogtail.apps.categories import * class EpiphanyApp(Application, WebBrowser): """Utility wrapper for Epiphany; implements the Webbrowser mixin interface""" def __init__(self): Application.__init__(self, root.application("epiphany")) self.epiPackageName="epiphany" self.epiVersion = packageDb.getVersion(self.epiPackageName) print "Epiphany version %s"%self.epiVersion def getMainWindow(self): fileMenuItem = self.menu("File") return EpiphanyWindow(fileMenuItem.findAncestor(predicate.IsAWindow())) def browseToUrl(self, urlString): window = self.getMainWindow() window.browseToUrl(urlString) class EpiphanyWindow(Window, WebBrowser): def __init__(self, node): Window.__init__(self, node) self.pageTabList = self.child(roleName='page tab list', debugName='Page Tab List') def newTab(self): # Click on File->New Tab on some epiphany window: newTabMenuItem = self.menu("File").menuItem("New Tab") newTabMenuItem.click() tabs = self.tabs() return tabs[-1] def goBack(self): goBackMenuItem = self.menu("Go").menuItem("Back") goBackMenuItem.click() def tabs(self): """ FIXME: not true: Get all tabs of this window as a list of EpiphanyTab instances """ return self.pageTabList.findChildren (predicate.GenericPredicate(roleName='page tab'), recursive=True) def browseToUrl(self,urlString): # Set URL: self.urlEntry().text = urlString self.urlEntry().actions["activate"].do() def urlEntry(self): """ Get the text entry Node for entering URLs. FIXME: this is currently something of a hack """ # FIXME: we hope that this gives us the correct text entry: return self.child(roleName='text', debugName='URL Entry') import dogtail.config from os import path import time #dogtail.config.Config.debugSearching=True ep = EpiphanyApp() window = ep.getMainWindow() #window.newTab() #run("capture-pixmap firefox") #run("mem-monitor-plotter") # First open 10 in the same tab for i in range(50): print "Open file " + str(i+1) window.browseToUrl("file://"+path.abspath("data/index-%03d.html" % (i+1))) # Give it time to open time.sleep(2) os.spawnlp(os.P_WAIT, "pkill", "pkill", "-SIGUSR1", "-f", "mem-monitor-plotter") os.spawnlp(os.P_WAIT, "pkill", "pkill", "-SIGUSR1", "-f", "epiphany") os.spawnlp(os.P_WAIT, "pkill", "pkill", "-SIGUSR2", "-f", "mem-monitor-plotter") os.spawnlp(os.P_WAIT, "pkill", "pkill", "-SIGUSR2", "-f", "epiphany")