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

« back to all changes in this revision

Viewing changes to examples/google-search.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
 
#!/usr/bin/env python
2
 
# Dogtail demo script
3
 
__author__ = 'David Malcolm <dmalcolm@redhat.com>'
4
 
 
5
 
# Test of filling in a form in a web browser
6
 
# Under construction.  Doesn't yet work
7
 
 
8
 
from dogtail.apps.wrappers.epiphany import *
9
 
 
10
 
class GoogleFrontPage(Node):
11
 
    def __init__(self, node):
12
 
        Node.__init__(self, node)
13
 
        self.searchButton = self.button('Google Search')
14
 
        self.imFeelingLuckyButton = self.button("I'm Feeling Lucky")
15
 
 
16
 
        # Locate the text entry dialog as a sibling of the search button
17
 
        self.textEntry = self.searchButton.parent.child(roleName='text', debugName='Search String Text Entry')
18
 
 
19
 
import dogtail.config
20
 
dogtail.config.config.debugSearching=True
21
 
 
22
 
# Epiphany doesn't seem to set the sensitivity state on buttons in web pages:
23
 
dogtail.config.config.ensureSensitivity=False
24
 
 
25
 
wb = EpiphanyApp()
26
 
 
27
 
# Browse to Google front page
28
 
tab = wb.browseToUrl("http://www.google.com")
29
 
tab.dump()
30
 
 
31
 
gfp = GoogleFrontPage(tab)
32
 
 
33
 
# Debug dump:
34
 
gfp.child(roleName='text').dump()
35
 
 
36
 
# Do a search:
37
 
gfp.textEntry.text = "zombie pirates"
38
 
print gfp.searchButton.actions[0]
39
 
gfp.searchButton.press()
40
 
 
41
 
 
42
 
# Scrape out the results:
43
 
frame = gfp.child(roleName='frame')
44
 
results = frame.findChildren(predicate.GenericPredicate(roleName='text'), recursive=False)
45
 
for result in results:
46
 
    print "Result:"
47
 
    print result.text
48
 
    print "--------------------------------------"
49
 
 
50
 
 
51