Пример #1
0
    def test_top_window(self):
        """Test that top_window_() works correctly"""
        app = Application()
        self.assertRaises(AppNotConnected, app.top_window_)

        app.start(_notepad_exe())

        self.assertEqual(app.UntitledNotepad.handle, app.top_window_().handle)

        app.UntitledNotepad.MenuSelect("Help->About Notepad")

        self.assertEqual(app.AboutNotepad.handle, app.top_window_().handle)

        app.AboutNotepad.Ok.Click()
        app.UntitledNotepad.MenuSelect("File->Exit")
        app.UntitledNotepad.WaitNot('exists')
        self.assertRaises(RuntimeError, app.top_window_)
Пример #2
0
    def test_top_window(self):
        """Test that top_window_() works correctly"""
        app = Application()
        self.assertRaises(AppNotConnected, app.top_window_)
        
        app.start(_notepad_exe())

        self.assertEqual(app.UntitledNotepad.handle, app.top_window_().handle)

        app.UntitledNotepad.MenuSelect("Help->About Notepad")

        self.assertEqual(app.AboutNotepad.handle, app.top_window_().handle)

        app.AboutNotepad.Ok.Click()
        app.UntitledNotepad.MenuSelect("File->Exit")
        app.UntitledNotepad.WaitNot('exists')
        self.assertRaises(RuntimeError, app.top_window_)
Пример #3
0
 def setUp(self):
     """Start the application set some data and ensure the application
     is in the state we want it."""
     self.tm = _ready_timeout
     app = Application()
     app.start(os.path.join(mfc_samples_folder, u"TrayMenu.exe"))
     self.app = app
     self.dlg = app.top_window_()
     self.dlg.Wait('ready', timeout=self.tm)
Пример #4
0
 def safari(self):
     try:
         app = Application()
         app.connect_(path=r"C:\Program Files\Safari\Safari.exe")
         safari = app.top_window_()
         safari.TypeKeys("{F5}")
     except (WindowNotFoundError, ProcessNotFoundError):
         self.safari64()
         pass
Пример #5
0
 def safari(self):
     try:
         app = Application()
         app.connect_(path=r'C:\Program Files\Safari\Safari.exe')
         safari = app.top_window_()
         safari.TypeKeys('{F5}')
     except (WindowNotFoundError, ProcessNotFoundError):
         self.safari64()
         pass
Пример #6
0
 def safari64(self):
     # Safari can be installed under either Program Files directories when
     # running 64bit Windows. We call this method if the other one errors out.
     try:
         app = Application()
         app.connect_(path=r'C:\Program Files (x86)\Safari\Safari.exe')
         safari = app.top_window_()
         safari.TypeKeys('{F5}')
     except (WindowNotFoundError, ProcessNotFoundError):
         pass
Пример #7
0
 def safari64(self):
     # Safari can be installed under either Program Files directories when
     # running 64bit Windows. We call this method if the other one errors out.
     try:
         app = Application()
         app.connect_(path=r"C:\Program Files (x86)\Safari\Safari.exe")
         safari = app.top_window_()
         safari.TypeKeys("{F5}")
     except (WindowNotFoundError, ProcessNotFoundError):
         pass
Пример #8
0
 def safari(self):
     try:
         app = Application()
         app.connect_(path=r'C:\Program Files\Safari\Safari.exe') 
         ie = app.top_window_()
         ie.TypeKeys('{F5}')
         if self.is64bit:
             self.TypeKeys64()
     except (WindowNotFoundError, ProcessNotFoundError):
         self.safari64()
         pass
Пример #9
0
    def defocus(self):
        target_name = "제목 없음 - 메모장"
        print(target_name)
        app = Application()

        app.connect(title_re=".*%s.*" % target_name)

        # Access app's window object
        app_dialog = app.top_window_()

        app_dialog.Minimize()
        app_dialog.Restore()
        app_dialog.SetFocus()
Пример #10
0
    def testClickCustomizeButton(self):
        "Test click on the 'show hidden icons' button"

        # Minimize to tray
        self.dlg.Minimize()
        _wait_minimized(self.dlg)

        # Make sure that the hidden icons area is enabled
        orig_hid_state = _toggle_notification_area_icons(
                show_all=False,
                debug_img="%s_01" % (self.id())
                )

        # Run one more instance of the sample app
        # hopefully one of the icons moves into the hidden area
        app2 = Application()
        app2.start(os.path.join(mfc_samples_folder, u"TrayMenu.exe"))
        dlg2 = app2.top_window_()
        dlg2.Wait('visible', timeout=self.tm)
        dlg2.Minimize()
        _wait_minimized(dlg2)

        # Test click on "Show Hidden Icons" button
        taskbar.ShowHiddenIconsButton.ClickInput()
        niow_dlg = taskbar.explorer_app.Window_(
                class_name='NotifyIconOverflowWindow')
        niow_dlg.OverflowNotificationAreaToolbar.Wait('ready', timeout=self.tm)
        niow_dlg.SysLink.ClickInput()
        nai = taskbar.explorer_app.Window_(
                title="Notification Area Icons",
                class_name="CabinetWClass"
                )
        origAlwaysShow = nai.CheckBox.GetCheckState()
        if not origAlwaysShow:
            nai.CheckBox.ClickInput()
        nai.OK.Click()

        # Restore Notification Area settings
        _toggle_notification_area_icons(show_all=orig_hid_state,
                                        debug_img="%s_02" % (self.id()))

        # close the second sample app
        dlg2.SendMessage(win32defines.WM_CLOSE)
Пример #11
0
    def testClickHiddenIcon(self):
        """
        Test minimizing a sample app into the hidden area of the tray
        and restoring the app back
        """

        if is_x64_Python() != is_x64_OS():
            # We don't run this test for mixed cases:
            # a 32-bit Python process can't interact with
            # a 64-bit explorer process (taskbar) and vice versa
            return

        # Make sure that the hidden icons area is enabled
        orig_hid_state = _toggle_notification_area_icons(
                show_all=False,
                debug_img="%s_01" % (self.id())
                )

        self.dlg.Minimize()
        _wait_minimized(self.dlg)

        # Run one more instance of the sample app
        # hopefully one of the icons moves into the hidden area
        app2 = Application()
        app2.start(os.path.join(mfc_samples_folder, u"TrayMenu.exe"))
        dlg2 = app2.top_window_()
        dlg2.Wait('visible', timeout=self.tm)
        dlg2.Minimize()
        _wait_minimized(dlg2)

        # Click in the hidden area
        taskbar.explorer_app.WaitCPUUsageLower(threshold=5, timeout=40)
        taskbar.ClickHiddenSystemTrayIcon('MFCTrayDemo', double=True)
        self.dlg.Wait('visible', timeout=self.tm)

        # Restore Notification Area settings
        _toggle_notification_area_icons(show_all=orig_hid_state,
                                        debug_img="%s_02" % (self.id()))

        dlg2.SendMessage(win32defines.WM_CLOSE)
Пример #12
0
    def convert_files(self, file):
        _config = Config()
        backslash = "\\"
        app_path = _config.Original_Path + backslash + file
        #print(app_path)
        Auto = Automate()
        renderTime = Auto.renderTime(app_path, _config.Rendering_wait_time)
        IsFileCopied = Auto.IsCopyFinished(app_path)
        if IsFileCopied == 0:
            return
        if os.path.exists(app_path):
            os.startfile(app_path)
        else:
            log.logger.info("Trec file does not exists")
            return
        time.sleep(_config.App_time)
        # print("Sleep End!!!")

        try:
            if os.path.exists(_config.Camtasia_Path):
                app = Application().connect(path=_config.Camtasia_Path)
            else:
                log.logger.info("Camtasia executable not found!")
                return

            # To bring the Camtasia window to the focus.
            app_dialog = app.top_window_()
            app_dialog.Minimize()
            app_dialog.Restore()
        except (ProcessNotFoundError):
            log.logger.info("Not Camtasia process found... Exiting App")
            return
        except (WindowNotFoundError):
            log.logger.info("Not found Camtasia... Exiting App")
            app.kill()
            return
        except (WindowAmbiguousError):
            log.logger.info(
                "There are too many Camtasia windows found... Exiting App")
            app.kill()
            return

        if os.path.exists(app_path):
            os.startfile(app_path)
        else:
            log.logger.info("Trec file does not exists... Exiting App")
            app.kill()
            return

        #for TRIAL
        if _config.Trial == 'YES':
            try:
                app.Window_(best_match='Dialog',
                            top_level_only=True).ChildWindow(
                                best_match='Finish').Click()
            except (MatchError):
                # print ' Not found Finish Dialog'
                log.logger.info("Not found Finish Dialog... Exiting App")
                app.kill()
                return

        time.sleep(_config.Dialog_wait_time)
        #end for TRIAL
        child_elements = app[_config.App_Name]
        #for clicking the share button
        child_elements.ClickInput(coords=(_config.Share_Btn_X,
                                          _config.Share_Btn_Y))
        child_elements.TypeKeys("{DOWN}")
        child_elements.TypeKeys("{ENTER}")
        time.sleep(_config.Dialog_wait_time)

        #for TRIAL
        if _config.Trial == 'YES':
            #for clicking the water mark button
            child_elements.Wait('visible', timeout=20)
            child_elements.ClickInput(coords=(_config.Water_Mark_Btn_X,
                                              _config.Water_Mark_Btn_Y))
            time.sleep(_config.Dialog_wait_time)
        #end for TRIAL
        for i in range(_config.Dialogs):
            time.sleep(2)
            child_elements.Wait('visible', timeout=20)

            try:
                app.Window_(best_match='Dialog',
                            top_level_only=True).ChildWindow(
                                best_match='Next').Click()
            except (MatchError):
                # print ' Not found Dialog to click the first Next. Check if coordinates are mentioned correctly in configuration.xml'
                log.logger.info(
                    "Not found Dialog to click the first Next. Check if coordinates are mentioned correctly in configuration.xml. Exiting App"
                )
                app.kill()
                return

        stripped_file_name = os.path.splitext(os.path.basename(file))[0]
        dup_dir = Auto.check_duplicate(stripped_file_name, _config.Saved_Path)
        if dup_dir == 1:
            log.logger.info(
                "Duplicate exists.The rendering will overwrite the existing directory"
            )

        try:
            app.Window_(best_match='Dialog', top_level_only=True).ChildWindow(
                title="Untitled Project",
                class_name="Edit").SetText(stripped_file_name)
        except (MatchError):
            # print ' Not found Dialog to rename the project'
            log.logger.info(
                "Not found Dialog to rename the project... Exiting App")
            app.kill()
            return
        try:
            app.Window_(
                best_match='Dialog',
                top_level_only=True).ChildWindow(best_match='Finish').Click()
        except (MatchError):
            # print ' Not found Dialog to click Finish'
            log.logger.info("Not found Dialog to click Finish... Exiting App")
            app.kill()
            return

        time.sleep(renderTime)
        app.kill_()
        time.sleep(_config.Dialog_wait_time)
        #print("Rendering Succcessful")

        return stripped_file_name
Пример #13
0
path = 'E:\\hong\\Debug'
base = 'C:\\Users\\Admin\\Documents\\rule\\edit_rule'
for link in os.listdir(base):
	if 'txt' in link:
		links = (base + '\\' + link).replace('\\','\\\\')
		with open(links, 'r',encoding='utf-8') as rules:
			data = rules.read()
		rules.close()
# print(data)

for files in os.listdir(path):
    if files == 'Tornado.exe':
        file_name = (path + '\\' + files).replace('\\', '\\\\')
        app = Application(backend="win32").start(file_name)
        time.sleep(1)
        app.top_window_().TypeKeys("tornado{TAB}tornado{TAB}{END}{BACKSPACE}211.109.9.60{TAB}19100{TAB 2}{ENTER}")
        time.sleep(5)
        app.top_window_().TypeKeys("{TAB 9}")
        app.top_window_().TypeKeys("{TAB 3}{DOWN}{RIGHT}{DOWN 12    }{RIGHT}{ENTER}{TAB 2}")
        time.sleep(1)


        app.top_window_().TypeKeys("{DOWN 5}{RIGHT}")
        time.sleep(1)
        app.top_window_().TypeKeys("{ENTER}{TAB 2}{DOWN 6}{RIGHT}")
        time.sleep(1)
        # app.top_window_().TypeKeys("{ENTER}{TAB 2}{DOWN 27}{RIGHT}")
        # time.sleep(1)
        # app.top_window_().TypeKeys("{ENTER}{TAB 2}{DOWN 104}{RIGHT}")
        # time.sleep(2)
        app.top_window_().TypeKeys("{ENTER}{TAB 2}{DOWN 7}")
Пример #14
0
    def RunTestTool(self, year, quarter, sleeptime):
      
        Timings.Defaults()
        app = Application()
        try:
            app.connect_(title_re = ".*a.*")
            sys.stderr.write ( 'connected to window '+'\n')
        except:
            import sys, string, os
            app.start_('C:\\MYP\\Python\\start.bat')
            time.sleep(5)
            app.connect_(title_re = ".*a.*")
            sys.stderr.write ( 'connected to window '+'\n')
        app.connect_(title_re = ".*a.*")
      
        app.top_window_().Restore()
        Timings.Fast()
        window = app.window_(process=18000)
        window.SetFocus()
        time.sleep(5)
        app.top_window_().Click()
        time.sleep(5)
        #window.TypeKeys("{TAB 2}")
        window.TypeKeys("{RIGHT 2}")
        window.TypeKeys("{TAB 4}")
        sys.stderr.write ( 'tabbing completed'+'\n')
        dict =  app.top_window_()._ctrl_identifiers()
        print dict
        for k,v  in dict.items():
            #print v
            for v1 in v:
                if (v1==u'a'):
                    print k.handle
                    #k.Click()



        app.top_window_().YearComboxBox.Select(year)


        #app.top_window_().ComboBox7.Select("a")
        app.top_window_()['a'].Click()

        sys.stderr.write ( 'Setting Options and Clicked'+'\n')
       
        print app.top_window_().PopulationComboBox1.ItemTexts()
        measures= []
        measures = app.top_window_().PopulationComboBox1.ItemTexts()
        print measures
        mmap= {

                'a':['b'],
             
            }

        #from collections import OrderedDict
        #mmap1={}
        #mmap1=OrderedDict((mmap[key], True) for key in mmap)
        measures=mmap.keys()
        measures.sort()
        s=''
        s1=''
        dictErrors ={}
        i=0
        previousError=''
        previousSkip=''
        for measure in measures:
            i=i+1
            #if(i==6):
                #break
            print 'using '
            print measure
            indicators=[]
            indicators=mmap[measure]

            if not measure == '': # Change the not operator if you want to run it for all cases in one go.
                app.top_window_().PopulationComboBox1.Select(measure)
                #indicators= app.top_window_().IndicatorComboBox3.ItemTexts()
                for indicator in indicators:
                    if indicator == '':
                        continue
                    app.top_window_().IndicatorComboBox3.Select(indicator)
                    app.top_window_()['Create and Run TestsButton'].Click()
                    #app.top_window_()['Create and Run TestsButton'].Click()
                    #time.sleep(12)

                    while(True):
                        time.sleep(1)
                        times_Run = app.top_window_()['Testing:Edit'].Texts()[0].strip(" ").split()[0]
                        if(times_Run=='00100'):
                            s1=app.top_window_()['Skip Logic ErrorsEdit2'].Texts()[0].strip(" ")
                            s = app.top_window_()['Measure Engine ErrorsEdit2'].Texts()[0].strip(" ")
                            print s
                            print s1
                            break



                #print dictErrors
        sleeptime = 30
        errors=''



        time.sleep(sleeptime)
        sys.stderr.write ( 'Slept for '+str(sleeptime)+'\n')
        #print s+s1

        #s1 = app.top_window_()['Skip Logic ErrorsEdit2'].Texts()[0]
        #s = app.top_window_()['Measure Engine ErrorsEdit2'].Texts()[0]
        print errors
        print dictErrors
        if(errors != '' ):
            raise AssertionError(errors)
            app.start_('C:\\MYP\\Python\\stop.bat')
        print 'reached3'

        #MayNotWork app.kill()
        app.start_('C:\\MYP\\Python\\stop.bat')
        sys.stderr.write ( 'All done')
Пример #15
0
from pywinauto.application import Application
from pywinauto import timings

app = Application().start(
    "C:\\projects\\foo-rpc\\portable_test\\foobar2000.exe /config")
quick_config = timings.WaitUntilPasses(
    3, 0.5, lambda: app.window_(title='Quick Appearance Setup'))
quick_config.Close()

window = app.top_window_()['Tree2']
playback = window.GetItem('\\Playback')
playback.Expand()
output = playback.GetChild('Output')
output.Select()
output_page = app.top_window_()
output_page['ComboBox'].Select('Null Output')
output_page['OK'].Click()
parser = argparse.ArgumentParser(description='')
parser.add_argument('--csv')

args = parser.parse_args()
csvFile = args.csv
hosts = {}

projectDir=os.path.abspath(os.getcwd())

import csv
with open(csvFile, 'r') as f:
    reader = csv.reader(f)
    hosts = dict((rows[0].strip(),rows[1].strip()) for rows in reader)

for key in hosts.iterkeys():
    app = Application().Start(cmd_line=u'"C:\\Program Files (x86)\\Crestron\\Toolbox\\Toolbox.exe" ')
    installerstoolboxappclass = app.InstallersToolboxAppClass
    installerstoolboxappclass.Wait('ready', timeout=30)
    button = installerstoolboxappclass.Button2
    button.Click()

    editWindow = app.Window_(title="Edit Address")
    editWindow.Wait('ready',timeout=30).TypeKeys(hosts[key]).TypeKeys('{ENTER}')
    #wineditAddressWindowdow.Wait('ready', timeout=30)

    #window.TypeKeys("{TAB 5}")
    #window.TypeKeys("{SPACE}")
    app.top_window_().DrawOutline()

    app.Kill_()
Пример #17
0
args = parser.parse_args()
csvFile = args.csv
hosts = {}

projectDir = os.path.abspath(os.getcwd())

import csv
with open(csvFile, 'r') as f:
    reader = csv.reader(f)
    hosts = dict((rows[0].strip(), rows[1].strip()) for rows in reader)

for key in hosts.iterkeys():
    app = Application().Start(
        cmd_line=u'"C:\\Program Files (x86)\\Crestron\\Toolbox\\Toolbox.exe" ')
    installerstoolboxappclass = app.InstallersToolboxAppClass
    installerstoolboxappclass.Wait('ready', timeout=30)
    button = installerstoolboxappclass.Button2
    button.Click()

    editWindow = app.Window_(title="Edit Address")
    editWindow.Wait('ready',
                    timeout=30).TypeKeys(hosts[key]).TypeKeys('{ENTER}')
    #wineditAddressWindowdow.Wait('ready', timeout=30)

    #window.TypeKeys("{TAB 5}")
    #window.TypeKeys("{SPACE}")
    app.top_window_().DrawOutline()

    app.Kill_()