コード例 #1
0
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.fast()

        self.app = Application()
        self.app.start(os.path.join(mfc_samples_folder, u"CmnCtrl3.exe"))
        self.app2 = Application().start(_notepad_exe())
コード例 #2
0
ファイル: afmstest.py プロジェクト: VCTLabs/afms
 def setTiming(self, speed):
     if speed.lower() == 'slow':
         Timings.Slow()
     elif speed.lower() == 'fast':
         Timings.Fast()
     else:
         Timings.Defaults()
コード例 #3
0
def image_rate(glab_path, image_path, size, color):
    if size not in test_sizes:
        return "[size error]"
    if color not in test_colors:
        return "[color error]"

    Timings.slow()
    mainw = connect_glab()
    if not mainw:
        mainw = start_glab(glab_path)
    else:
        if settings['run'] > RUN_LIMIT:
            close_glab(mainw)
            mainw = start_glab(glab_path)
            settings['run'] = 0

    if not mainw:
        return '[run error]'

    settings['run'] = settings['run'] + 1

    start_time = time.time()
    rate = get_color_rate(mainw, image_path, size, color)
    end_time = time.time()
    image = ImageDesc(image_path, size, color, rate)
    print(image.to_json() + ": " + str(end_time - start_time) + " sec")
    return image.to_json()
コード例 #4
0
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.defaults()

        app = Application()

        path = os.path.split(__file__)[0]
        test_file = os.path.join(path, "test.txt")

        with codecs.open(test_file, mode="rb", encoding='utf-8') as f:
            self.test_data = f.read()
        # remove the BOM if it exists
        self.test_data = self.test_data.replace(repr("\xef\xbb\xbf"), "")
        #self.test_data = self.test_data.encode('utf-8', 'ignore') # XXX: decode raises UnicodeEncodeError even if 'ignore' is used!
        print('self.test_data:')
        print(self.test_data.encode('utf-8', 'ignore'))

        app.start("Notepad.exe " + test_file, timeout=20)

        self.app = app
        self.dlg = app.UntitledNotepad
        self.ctrl = self.dlg.Edit.wrapper_object()

        self.old_pos = self.dlg.rectangle

        self.dlg.move_window(10, 10, 400, 400)
コード例 #5
0
    def setUp(self):
        """Start the sample application. Open a tab with ownerdraw button."""
        Timings.defaults()

        self.app = Application().start(os.path.join(mfc_samples_folder, u"RebarTest.exe"))
        # open the Help dailog
        self.app.active().type_keys('%h{ENTER}')
コード例 #6
0
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.fast()

        self.app = Application()
        self.app.start(os.path.join(mfc_samples_folder, u"CmnCtrl3.exe"))
        self.app2 = Application().start(_notepad_exe())
コード例 #7
0
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.defaults()

        app = Application()

        path = os.path.split(__file__)[0]
        test_file = os.path.join(path, "test.txt")

        with codecs.open(test_file, mode="rb", encoding='utf-8') as f:
            self.test_data = f.read()
        # remove the BOM if it exists
        self.test_data = self.test_data.replace(repr("\xef\xbb\xbf"), "")
        #self.test_data = self.test_data.encode('utf-8', 'ignore') # XXX: decode raises UnicodeEncodeError even if 'ignore' is used!
        print('self.test_data:')
        print(self.test_data.encode('utf-8', 'ignore'))

        app.start("Notepad.exe " + test_file, timeout=20)

        self.app = app
        self.dlg = app.UntitledNotepad
        self.ctrl = self.dlg.Edit.WrapperObject()

        self.old_pos = self.dlg.rectangle

        self.dlg.MoveWindow(10, 10, 400, 400)
コード例 #8
0
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.defaults()

        self.app = Application().start(os.path.join(mfc_samples_folder, u"BCDialogMenu.exe"))
        self.dlg = self.app.BCDialogMenu
        self.app.wait_cpu_usage_lower(threshold=1.5, timeout=30, usage_interval=1)
        self.dlg.wait('ready')
コード例 #9
0
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.defaults()

        self.app = Application()
        self.app.start("Notepad.exe")

        self.dlg = self.app.Notepad
コード例 #10
0
 def setUp(self):
     """Set some data and ensure the application is in the state we want"""
     Timings.fast()
     actionlogger.enable()
     self.app = Application().start(_notepad_exe())
     self.logger = logging.getLogger('pywinauto')
     self.out = self.logger.handlers[0].stream
     self.logger.handlers[0].stream = open('test_logging.txt', 'w')
コード例 #11
0
ファイル: test_hwndwrapper.py プロジェクト: sugus86/pywinauto
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.defaults()

        self.app = Application().start(os.path.join(mfc_samples_folder, u"RowList.exe"))

        self.dlg = self.app.RowListSampleApplication
        self.ctrl = self.app.RowListSampleApplication.ListView.wrapper_object()
コード例 #12
0
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.defaults()

        self.app = Application()
        self.app.start("Notepad.exe")

        self.dlg = self.app.Notepad
コード例 #13
0
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.defaults()

        self.app = Application().start(os.path.join(mfc_samples_folder, u"RowList.exe"))

        self.dlg = self.app.RowListSampleApplication
        self.ctrl = self.app.RowListSampleApplication.ListView.wrapper_object()
コード例 #14
0
 def setUp(self):
     """Set some data and ensure the application is in the state we want"""
     Timings.fast()
     actionlogger.enable()
     self.app = Application().start(_notepad_exe())
     self.logger = logging.getLogger('pywinauto')
     self.out = self.logger.handlers[0].stream
     self.logger.handlers[0].stream = open('test_logging.txt', 'w')
コード例 #15
0
    def setUp(self):
        """Start the sample application. Open a tab with ownerdraw button."""
        Timings.defaults()

        self.app = Application().Start(
            os.path.join(mfc_samples_folder, u"RebarTest.exe"))
        # open the Help dailog
        self.app.active_().type_keys('%h{ENTER}')
コード例 #16
0
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.fast()

        self.app = Application()
        self.app.start(_notepad_exe())

        self.dlg = self.app.UntitledNotepad
        self.ctrl = HwndWrapper(self.dlg.Edit.handle)
コード例 #17
0
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.defaults()

        self.app = Application()
        self.app.start(os.path.join(mfc_samples_folder, u"CmnCtrl1.exe"))

        self.dlg = self.app.Common_Controls_Sample
        self.ctrl = self.dlg.TreeView.wrapper_object()
コード例 #18
0
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.fast()

        self.app = Application().start(os.path.join(mfc_samples_folder, u"CmnCtrl3.exe"))

        self.dlg = self.app.Common_Controls_Sample
        self.dlg.TabControl.select('CButton (Command Link)')
        self.ctrl = HwndWrapper(self.dlg.Command_button_here.handle)
コード例 #19
0
ファイル: test_clipboard.py プロジェクト: pywinauto/pywinauto
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.fast()
        EmptyClipboard()
        self.app1 = Application().start("notepad.exe")
        self.app2 = Application().start("notepad.exe")

        self.app1.UntitledNotepad.move_window(RECT(0, 0, 200, 200))
        self.app2.UntitledNotepad.move_window(RECT(0, 200, 200, 400))
コード例 #20
0
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.defaults()

        self.app = Application()
        self.app.start(os.path.join(mfc_samples_folder, u"CmnCtrl1.exe"))

        self.dlg = self.app.Common_Controls_Sample
        self.ctrl = self.dlg.TreeView.wrapper_object()
コード例 #21
0
ファイル: test_clipboard.py プロジェクト: seuzht/pywinauto
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.fast()
        EmptyClipboard()
        self.app1 = Application().start("notepad.exe")
        self.app2 = Application().start("notepad.exe")

        self.app1.UntitledNotepad.MoveWindow(RECT(0, 0, 200, 200))
        self.app2.UntitledNotepad.MoveWindow(RECT(0, 200, 200, 400))
コード例 #22
0
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.fast()

        self.app = Application()
        self.app.start(_notepad_exe())

        self.dlg = self.app.UntitledNotepad
        self.ctrl = HwndWrapper(self.dlg.Edit.handle)
コード例 #23
0
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.defaults()

        # start the application
        self.app = Application(backend='win32')
        self.app = self.app.start(mfc_app_1)

        self.dlg = self.app.CommonControlsSample
コード例 #24
0
ファイル: test_hwndwrapper.py プロジェクト: sugus86/pywinauto
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.fast()

        self.app = Application().start(os.path.join(mfc_samples_folder, u"CmnCtrl3.exe"))

        self.dlg = self.app.Common_Controls_Sample
        self.dlg.TabControl.select('CButton (Command Link)')
        self.ctrl = HwndWrapper(self.dlg.Command_button_here.handle)
コード例 #25
0
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.fast()

        self.app1 = Application().start(u"cmd.exe",
                                        create_new_console=True,
                                        wait_for_idle=False)
        self.app2 = Application().start(os.path.join(
            mfc_samples_folder, u"CmnCtrl2.exe"))
        self.app2.wait_cpu_usage_lower(threshold=1.5, timeout=30, usage_interval=1)
コード例 #26
0
ファイル: test_hwndwrapper.py プロジェクト: sugus86/pywinauto
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.fast()

        self.app1 = Application().start(u"cmd.exe",
                                        create_new_console=True,
                                        wait_for_idle=False)
        self.app2 = Application().start(os.path.join(
            mfc_samples_folder, u"CmnCtrl2.exe"))
        self.app2.wait_cpu_usage_lower(threshold=1.5, timeout=30, usage_interval=1)
コード例 #27
0
        def setUp(self):
            """Set some data and ensure the application is in the state we want"""
            Timings.slow()

            self.app = Application(backend="uia")
            self.app = self.app.start(wpf_app_1)

            self.dlg = self.app.WPFSampleApplication
            self.handle = self.dlg.handle
            self.ctrl = UIAElementInfo(self.handle)
コード例 #28
0
        def setUp(self):
            """Set some data and ensure the application is in the state we want"""
            Timings.slow()

            self.app = Application(backend="uia")
            self.app = self.app.start(wpf_app_1)

            self.dlg = self.app.WPFSampleApplication
            self.handle = self.dlg.handle
            self.ctrl = UIAElementInfo(self.handle)
コード例 #29
0
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.defaults()

        self.app = Application().start(
            os.path.join(mfc_samples_folder, u"BCDialogMenu.exe"))
        self.dlg = self.app.BCDialogMenu
        self.app.wait_cpu_usage_lower(threshold=1.5,
                                      timeout=30,
                                      usage_interval=1)
        self.dlg.wait('ready')
コード例 #30
0
ファイル: test_taskbar.py プロジェクト: zwxf0112/pywinauto
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.defaults()

        self.tm = _ready_timeout
        app = Application(backend='win32')
        app.start(os.path.join(mfc_samples_folder, u"TrayMenu.exe"), wait_for_idle=False)
        self.app = app
        self.dlg = app.top_window()
        mouse.move((-500, 200))  # remove the mouse from the screen to avoid side effects
        self.dlg.wait('ready', timeout=self.tm)
コード例 #31
0
ファイル: test_mouse.py プロジェクト: pywinauto/pywinauto
 def setUp(self):
     """Set some data and ensure the application is in the state we want"""
     if sys.platform == 'win32':
         Timings.defaults()
         self.app = Application()
         self.app.start(_test_app())
         self.dlg = self.app.mousebuttons
     else:
         self.display = Display()
         self.app = subprocess.Popen("exec " + _test_app(), shell=True)
         time.sleep(1)
コード例 #32
0
 def setUp(self):
     """Set some data and ensure the application is in the state we want"""
     if sys.platform == 'win32':
         Timings.defaults()
         self.app = Application()
         self.app.start(_test_app())
         self.dlg = self.app.mousebuttons
     else:
         self.display = Display()
         self.app = subprocess.Popen("exec " + _test_app(), shell=True)
         time.sleep(1)
コード例 #33
0
ファイル: test_hwndwrapper.py プロジェクト: sugus86/pywinauto
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.fast()

        self.app = Application()
        self.app.start(_notepad_exe())

        self.dlg = self.app.window(title='Untitled - Notepad', class_name='Notepad')
        self.ctrl = HwndWrapper(self.dlg.Edit.handle)
        self.dlg.Edit.set_edit_text("Here is some text\r\n and some more")

        self.app2 = Application().start(_notepad_exe())
コード例 #34
0
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.fast()

        self.app = Application()
        self.app.start(_notepad_exe())

        self.dlg = self.app.window(title='Untitled - Notepad', class_name='Notepad')
        self.ctrl = HwndWrapper(self.dlg.Edit.handle)
        self.dlg.Edit.set_edit_text("Here is some text\r\n and some more")

        self.app2 = Application().start(_notepad_exe())
コード例 #35
0
 def matchXl_dict(self,year):
     self.book = xlrd.open_workbook(self.from_this_dir('C:\\MYP\\Python\\custom.xlsx'), formatting_info=False)
     self.sheet = self.book.sheet_by_name('Sheet1')
     xlval = self.sheet.col_values( 0,0,4)
     Timings.Defaults()
     app = Application()
     try:
         app.connect_(title_re = ".*Skip Logic.*")
     except:
         app.start_('C:\MYP\Swami-KT\MYP_09_00_00_93\QATools\start.bat')
         time.sleep(5)
         app.connect_(title_re = ".*Skip Logic.*")
           Timings.Fast()
コード例 #36
0
ファイル: afmstest.py プロジェクト: VCTLabs/afms
 def initTimings(self):
     Timings.window_find_timeout = 10
     Timings.app_start_timeout = 10
     Timings.exists_timeout = 5
     Timings.after_click_wait = .5
     Timings.after_clickinput_wait = .01
     Timings.after_menu_wait = .05
     Timings.after_sendkeys_key_wait = .01
     Timings.after_button_click_wait = 0
     Timings.before_closeclick_wait = 0.1
     Timings.closeclick_dialog_close_wait = 1.0
     Timings.after_closeclick_wait = 1.0
     Timings.after_windowclose_timeout = 2
     Timings.after_setfocus_wait = .06
     Timings.after_setcursorpos_wait = .01
     Timings.sendmessagetimeout_timeout = .001
     Timings.after_tabselect_wait = 1
     Timings.after_listviewselect_wait = .01
     Timings.after_listviewcheck_wait = .001
     Timings.after_treeviewselect_wait = 0.5
     Timings.after_toobarpressbutton_wait = .01
     Timings.after_updownchange_wait = .001
     Timings.after_movewindow_wait = 0
     Timings.after_buttoncheck_wait = 0
     Timings.after_comboboxselect_wait = 0
     Timings.after_listboxselect_wait = 0
     Timings.after_listboxfocuschange_wait = 0
     Timings.after_editsetedittext_wait = 0
     Timings.after_editselect_wait = 0
     Timings.Slow()
コード例 #37
0
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.Defaults()

        self.app = Application().Start(
            os.path.join(mfc_samples_folder, u"BCDialogMenu.exe"))
        self.dlg = self.app.BCDialogMenu
コード例 #38
0
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.Fast()

        self.app1 = Application().start(u"cmd.exe",
                                        create_new_console=True,
                                        wait_for_idle=False)
        self.app2 = Application().start(
            os.path.join(mfc_samples_folder, u"CmnCtrl2.exe"))
コード例 #39
0
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.Defaults()
        self.prev_warn = warnings.showwarning
        def no_warnings(*args, **kwargs): pass
        warnings.showwarning = no_warnings

        if is_x64_Python() or not is_x64_OS():
            self.notepad_subpath = r"system32\notepad.exe"
        else:
            self.notepad_subpath = r"SysWOW64\notepad.exe"
コード例 #40
0
 def sap_transfer(self, sheet, row, contract_num, app):
     Timings.Slow()
     #Display Contract:Header Data
     dlg_spec = app.Display_Contract_Header_Data
     actionable_dlg = dlg_spec.wait('visible')
     rect = app.Display_Contract_Header_Data['Pane6'].rectangle()
     #Get coordinates that will be used as reference to get the
     #data from SAP fields
     x_ref = rect.left
     y_ref = rect.top
     #get agreement start
     valid_start = None
     x = x_ref + 125
     y = y_ref + 125
     pyautogui.moveTo(x, y)
     pyautogui.click()
     pyautogui.click()
     pywinauto.mouse.press(button='left', coords=(x + FIELD_LENGTH - 1, y))
     time.sleep(0.2)
     valid_start = pyautogui.hotkey('ctrl', 'c')
     time.sleep(0.2)
     if valid_start is not None:
         sheet.cell(row=row, column=LISTINGS[3][1], value=valid_start)
     pywinauto.mouse.release(button='left', coords=(x + FIELD_LENGTH, y))
     #get agreement end
     valid_end = None
     x = x_ref + 330
     y = y_ref + 125
     pyautogui.moveTo(x, y)
     pyautogui.click()
     pyautogui.click()
     pywinauto.mouse.press(button='left', coords=(x + FIELD_LENGTH - 1, y))
     time.sleep(0.2)
     valid_end = pyautogui.hotkey('ctrl', 'c')
     time.sleep(0.2)
     if valid_end is not None:
         sheet.cell(row=row, column=LISTINGS[4][1], value=valid_end)
     pywinauto.mouse.release(button='left', coords=(x + FIELD_LENGTH, y))
     #get OA net
     oa_net = None
     x = x_ref + 161
     y = y_ref + 470
     pyautogui.moveTo(x, y)
     pyautogui.click()
     pyautogui.click()
     pywinauto.mouse.press(button='left', coords=(x + 102, y))
     time.sleep(0.2)
     oa_net = pyautogui.hotkey('ctrl', 'c')
     time.sleep(0.2)
     if oa_net is not None:
         sheet.cell(row=row, column=LISTINGS[2][1], value=oa_net)
     pywinauto.mouse.release(button='left', coords=(x + 101, y))
     #return to contract agreement page
     pyautogui.press('f3', interval=3)
コード例 #41
0
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.Defaults()

        self.tm = _ready_timeout
        app = Application(backend='win32')
        app.start(os.path.join(mfc_samples_folder, u"TrayMenu.exe"),
                  wait_for_idle=False)
        self.app = app
        self.dlg = app.top_window()
        self.dlg.Wait('ready', timeout=self.tm)
コード例 #42
0
def folder_rate(glab_path, image_folder):
    Timings.slow()
    imgs = []
    valid_images = ['.jpg', '.gif', '.png', '.tga']
    for f in os.listdir(image_folder):
        ext = os.path.splitext(f)[1]
        if ext.lower() not in valid_images:
            continue
        imgs.append(f)

    mainw = connect_glab()
    if not mainw:
        mainw = start_glab(glab_path)
    if not mainw:
        return '[run error]'

    json_report = '{\n'
    json_report = json_report + '    "images":\n'
    json_report = json_report + '    [\n'
    total_rate = [0, 0]
    for img in imgs:
        for size in test_sizes:
            for color in test_colors:
                start_time = time.time()
                rate = get_color_rate(mainw, image_folder + img, size, color)
                end_time = time.time()
                image = ImageDesc(image_folder + img, size, color, rate)
                json_report = json_report + '        ' + image.to_json(
                ) + ',\n'

                print(image.to_json() + ": " + str(end_time - start_time) +
                      " sec")

                total_rate[0] = total_rate[0] + rate[0]
                total_rate[1] = total_rate[1] + rate[1]
    json_report = json_report[:-1]
    json_report = json_report + '    ],\n'
    json_report = json_report + '    "total_rate": ' + str(total_rate) + '\n'
    json_report = json_report + '}'
    return json_report
コード例 #43
0
ファイル: neunkdemo.py プロジェクト: g41nxe/dlr-tdi-py
    def __init__(self):

        Timings.Slow()

        self.base_path = Config.get("CAM_RESULT_PATH")

        self.app = Application(backend="win32").connect(
            path=Config.get("CAM_PROGRAM_PATH"))
        self.dlg = self.app.Test9k

        self.frequency = self.dlg.Spinner4.get_buddy_control().text_block()

        return
コード例 #44
0
ファイル: navigation.py プロジェクト: vijaymandava/rmb
    def start(self):

        Timings.fast()  # divide all timings by two (~2x faster)
        #Timings.slow()  # divide all timings by two (~2x faster)

        try:
            self.app = Application(backend='uia').connect(
                path=self.app_path, allow_magic_lookup=False)
            # primary='uia'   alternative='win32'
        except Exception as e:
            print('Oops! when trying to connect to application ',
                  self.app_path)
            print('got a ', e.__class__)
            print(
                'note you need to run powershell as administrator to connect to SM'
            )
            sys.exit(1)

        self.confirm_home()
        y = self.pre_call_tasks()
        assert y is not None, "unable to perform pre_call_tasls()"
        print('testbench is ready')
コード例 #45
0
    def setUp(self):
        """Set some data and ensure the application is in the state we want"""
        Timings.Defaults()
        # Force Display User and Deprecation warnings every time
        # Python 3.3+nose/unittest trys really hard to suppress them
        for warning in (UserWarning, PendingDeprecationWarning):
            warnings.simplefilter('always', warning)

        mfc_samples_folder = os.path.join(os.path.dirname(__file__),
                                          r"..\..\apps\MFC_samples")
        if is_x64_Python():
            self.sample_exe = os.path.join(mfc_samples_folder, "x64",
                                           "CmnCtrl1.exe")
            self.sample_exe_inverted_bitness = os.path.join(
                mfc_samples_folder, "CmnCtrl1.exe")
        else:
            self.sample_exe = os.path.join(mfc_samples_folder, "CmnCtrl1.exe")
            self.sample_exe_inverted_bitness = os.path.join(
                mfc_samples_folder, "x64", "CmnCtrl1.exe")
コード例 #46
0
    def setUp(self):
        Timings.defaults()

        self.app = Application().start(os.path.join(mfc_samples_folder, u'CtrlTest.exe'))
        self.dlg = self.app.Control_Test_App
コード例 #47
0
 def setUp(self):
     """Set some data and ensure the application is in the state we want"""
     Timings.defaults()
     self.app = Application().start("notepad")
     self.dlghandle = self.app.UntitledNotepad.handle
     self.edit_handle = self.app.UntitledNotepad.Edit.handle
コード例 #48
0
def _set_timings_fast():
    """Set Timings.fast() and some slower settings for reliability"""
    Timings.fast()
    Timings.window_find_timeout = 3
    Timings.closeclick_dialog_close_wait = 2.