示例#1
0
def ReexecAionApp(testAppName):
    try:
        if not (os.path.exists(testAppDirectory + "\\" + testAppName + "\\" + testAppName + ".app")):
            print("Failed to find test application script app file")
            print("Exit code 2: The system cannot find the file specified.")
            exit(2)
        # We verified that app file exist and now lets try to process/interpret it with reecec
        appAion = Application().start(r"reexec " + testAppDirectory + "\\" + testAppName + "\\" + testAppName + ".app")
        while not appAion.Windows_():
            time.sleep(.5)
    except Exception:
        # Because appAion generated window will be present even if reexec reports failure, this will only fail if reexec itself fails to run
        print("Generic exception: Application failed to start")
        print("Error code 22: The device does not recognize the command.")
        exit(22)
    except:
        print("something else went wrong")
        sys.exit()
    print("Started test application run ...")
    while appAion['Dialog'].Exists():
        # Optional time delay
        time.sleep(.5)
        print(appAion['Dialog']['Static'].Texts())
        appAion['Dialog']['Button'].click()
    print("Done with reexec test")
示例#2
0
def RunCompiledAionApp(testAppName):
    try:
        if not (os.path.exists(testAppDirectory + "\\" + testAppName + "\\" +  testAppName + ".bin" + "\\" + "_" + testAppName + ".exe")):
            print("Failed to find test application binary")
            print("Exit code 2: The system cannot find the file specified.")
            print (testAppDirectory + "\\" + testAppName + "\\" +  testAppName + ".bin" + "\\" + "_" + testAppName + ".exe")
            exit(2)
        # We verified that app file exist and now lets try to process/interpret it with reecec
        appAion = Application().start(testAppDirectory + "\\" + testAppName + "\\" + testAppName + ".bin"+ "\\" + "_" + testAppName + ".exe")
        while not appAion.Windows_():
            time.sleep(.5)
    except Exception:
        # Because appAion is already tested for availability, this will only fail if binary itself fails to run
        print("Generic exception: Application binary failed to start")
        print("Error code 22: The device does not recognize the command.")
        exit(22)
    except:
        print("something else went wrong")
        sys.exit()
    print("Started test application run ...")
    while appAion['Dialog'].Exists():
        # Optional time delay
        time.sleep(.5)
        print(appAion['Dialog']['Static'].Texts())
        appAion['Dialog']['Button'].click()
    print("Done with binary run test")
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()
示例#4
0
goToTestExample = "cd  C:\TEMP\examples\Associate &&"
deleteOldLogsAndTestFiles = "rmdir associate.bin /s /q  &  del Out.log & dir > Out.log &&"
respawnApp = "  respawn associate.app >> Out.log  2>&1 "
cmdTestRoutineWin = goToTestExample + deleteOldLogsAndTestFiles + respawnApp
subprocess.call(cmdTestRoutineWin, shell=True)

file = open('C:\TEMP\examples\Associate\Out.log', 'r')
print(file.read())

#from pywinauto.application import Desktop
try:
    #appAion = Application().start(r"C:\TEMP\examples\Associate\associate.bin\_associate.exe")
    appAion = Application().start(
        r"reexec C:\TEMP\examples\Associate\associate.app")
    #Delay timer for applications that may be slower to initialize their GUI
    while not appAion.Windows_():
        time.sleep(.5)
except Exception:
    print("Generic exception: Application failed to start")
except:
    print("something else went wrong")
    sys.exit()
#appAion.print_control_identifiers()
print("Second round")

#Check for specific Dialog box window that in this case indicate missing test file
if appAion.window(title="Aion Init").Exists():
    print("Aion script that you are referencing does not exist.")
    print(appAion['Dialog'].Texts())
    print(appAion['Dialog']['Static'].GetProperties())
    print(appAion['Dialog']['Static'].Texts())