Ejemplo n.º 1
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)
Ejemplo n.º 2
0
 def setTiming(self, speed):
     if speed.lower() == 'slow':
         Timings.Slow()
     elif speed.lower() == 'fast':
         Timings.Fast()
     else:
         Timings.Defaults()
Ejemplo n.º 3
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}')
Ejemplo n.º 4
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
Ejemplo n.º 5
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.WrapperObject()
Ejemplo n.º 6
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
Ejemplo n.º 7
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.WrapperObject()
Ejemplo n.º 8
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
Ejemplo n.º 9
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)
Ejemplo n.º 10
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"
Ejemplo n.º 11
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)
Ejemplo n.º 12
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')
Ejemplo n.º 13
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()
Ejemplo n.º 14
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")
Ejemplo n.º 15
0
 def setUp(self):
     """Set some data and ensure the application is in the state we want"""
     Timings.Defaults()
     self.app = Application(backend='win32').start(
         os.path.join(mfc_samples_folder, u"CmnCtrl3.exe"))
     self.dlg = self.app.CommonControlsSample
Ejemplo n.º 16
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.dlgspec = self.app.UntitledNotepad
     self.ctrlspec = self.app.UntitledNotepad.Edit
Ejemplo n.º 17
0
	通过在对象timings.Timings 中设置全局静态变量(等待时间),它可以单独根据您的需要进行调整

	全局计时变量值的设置方法:
		Timings.defaults():将全局计时设置为默认值
		Timings.slow() :将所有时间加倍(使脚本执行速度降低约2倍)
		Timings.fast():将所有计时除以2(快2倍)
"""
from pywinauto.timings import wait_until, Timings

i = 0


def work():
    global i
    i += 1
    print("当前i的值为:", i)
    return i


# 等work返回的结果为5的时候,继续往下执行
wait_until(10, 1, work, 5)
print("等待通过")

# 将等待的计时器设为默认值
Timings.Defaults()

# 将等待时间加倍
Timings.Slow()

# 将等待时间减半
Timings.Fast()
Ejemplo n.º 18
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
Ejemplo n.º 19
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
Ejemplo n.º 20
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')