~ubuntu-branches/ubuntu/utopic/dogtail/utopic

« back to all changes in this revision

Viewing changes to dogtail/apps/wrappers/epiphany.py

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2006-12-21 13:33:47 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20061221133347-xo9jg11afp5plcka
Tags: upstream-0.6.1
ImportĀ upstreamĀ versionĀ 0.6.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
"""Wrapper code to help when scripting Epiphany
2
 
 
3
 
Author: David Malcolm <dmalcolm@redhat.com>"""
4
 
 
5
 
__author__ = 'David Malcolm <dmalcolm@redhat.com>'
6
 
 
7
 
from dogtail.tree import *
8
 
from dogtail.distro import *
9
 
from dogtail.apps.categories import *
10
 
 
11
 
class EpiphanyApp(Application, WebBrowser):
12
 
        """Utility wrapper for Epiphany; implements the Webbrowser mixin interface"""
13
 
 
14
 
        def __init__(self):
15
 
                Application.__init__(self, root.application("epiphany"))
16
 
 
17
 
                if isinstance(distro, Debian):
18
 
                        self.epiPackageName="epiphany-browser"
19
 
                else:
20
 
                        self.epiPackageName="epiphany"
21
 
                self.epiVersion = packageDb.getVersion(self.epiPackageName)
22
 
                print "Epiphany version %s"%self.epiVersion
23
 
 
24
 
        def browseToUrl(self, urlString):
25
 
                # Click on File->New Tab on some epiphany window:
26
 
                newTabMenuItem = self.menu("File").menuItem("New Tab")
27
 
                newTabMenuItem.click()
28
 
 
29
 
                window = EpiphanyWindow(newTabMenuItem.findAncestor(predicate.IsAWindow()))
30
 
 
31
 
                tabs = window.tabs()
32
 
 
33
 
                # Set URL:
34
 
                print window.urlEntry().extents
35
 
                window.urlEntry().text = urlString
36
 
                window.urlEntry().doAction('activate')
37
 
 
38
 
                # This is in the final tab; return it:
39
 
                return tabs[-1]
40
 
 
41
 
class EpiphanyWindow(Window):
42
 
        def __init__(self, node):
43
 
                Window.__init__(self, node)
44
 
                self.pageTabList = self.child(roleName='page tab list', debugName='Page Tab List')
45
 
 
46
 
        def tabs(self):
47
 
                """
48
 
                FIXME: not true: Get all tabs of this window as a list of EpiphanyTab instances
49
 
                """
50
 
                return self.pageTabList.findChildren (predicate.GenericPredicate(roleName='page tab'), recursive=True)
51
 
 
52
 
        def urlEntry(self):
53
 
                """
54
 
                Get the text entry Node for entering URLs.
55
 
                FIXME: this is currently something of a hack
56
 
                """
57
 
                # FIXME: we hope that this gives us the correct text entry:
58
 
                return self.child(roleName='text', debugName='URL Entry')
59
 
 
60
 
#        def newTab(self, url):
61
 
                
62
 
        
63
 
#class EpiphanyTab(Node):
64
 
#        def __init__(self, node, window):
65
 
#                Node.__init__(self, node)
66
 
#                self.window = window