ForteAgentSample.py :  » GUI » Python-Win32-GUI-Automation » pywinauto-0.4.0 » examples » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » GUI » Python Win32 GUI Automation 
Python Win32 GUI Automation » pywinauto 0.4.0 » examples » ForteAgentSample.py
"""Perform some tests with Forte Agent

NOTE: Forte Agent has a very dynamic interface
e.g. whether it is free or not, whether it is still in the grace
period. For this reason this example script may or may not work well
for you"""

print __doc__

import time
from pprint import pprint

from pywinauto.application import Application

# start the application and wait for the Agent Dialog to be ready
app = Application().start_(r"c:\program files\agent\agent.exe")

while not app.Windows_():
    time.sleep(.5)

# if the trial nag dialog pops up
if app.window_(title = "Forte Agent Trial").Exists():
    #app.ForteAgentTrial.IdLikeToContinueUsingAgentfor7moredays.Click()
    app.ForteAgentTrial.IdliketouseFreeAgent
    app.ForteAgentTrial.OK.Click()

if app.window_(title = "Free Agent Registration").Exists():
    app.FreeAgentRegistration.ImreallybusyRemindmein30.Click()
    app.FreeAgentRegistration.OK.CloseClick()

if app.window_(title = "What's New Reminder").Exists():
    app.WhatsNewReminder.ImreallybusyRemindmein90.Click()
    app.WhatsNewReminder.OK.CloseClick()



# wait until the app is ready
app.FreeAgent.Wait("ready")

# if we get the Agent Setup wizard pops up close it
if app.AgentSetupWizard.Cancel.Exists(1):
    app.AgentSetupWizard.Cancel.Click()
    app.AgentSetupWizard2.Yes.Click()

# Select to emtpy trash
app.FreeAgent.MenuSelect("File->EmptyTrash")
app.EmptyTrash.No.Click()

# Select some more menus (typo not important :-)
app.FreeAgent.MenuSelect("File->Purge and Compact -> Compact All Folders")
app.FreeAgent.OK.Click()

#print app.FreeAgent.MenuItem("File->Purge and compact").GetProperties()
#app.FreeAgent.MenuSelect("File->Purge and Compact->PurgeFolder")
#app.PurgeFoldersInDesks.Cancel.Click()


# this is strange - when I do it by hand this is "Purge Folder" but during
# automation the text of the menu item is Purge Selected Folders
# FIXED - need to init the sub menu!
app.FreeAgent.MenuSelect("File->Purge and Compact->Purge Folder")
app.AgentTip.OK.Click()

app.FreeAgent.MenuSelect("File->Import and Export->Import Messages")
app.ImportMessages.Cancel.Click()

app.FreeAgent.MenuSelect("File->Import and Export->Import Address Book")
app.ImportAddresses.Cancel.Click()

app.FreeAgent.MenuSelect("File->Import and Export->Export Address Book")
app.ExportAddresses.Cancel.Click()

# pick something other then a file menu item
app.FreeAgent.MenuSelect("Tools->ApplyFiltersToFolder")
if app.ToolsApplyFilters.OK.Exists():
    app.ToolsApplyFilters.OK.Click()

#app.AgentTip.OK.Click()
#app.ApplyFiltersToFolders.Cancel.Click()


print "==" * 20
print "The Agent File Menu..."
print "==" * 20
pprint (app.FreeAgent.MenuItems()[1])
try:
    app.FreeAgent.MenuSelect("File->Print")
    app.Print.Cancel.Click()
except:
    print "Print Menu was probably disabled"

# quit Agent
app.FreeAgent.MenuSelect("File -> Exit")
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.